How to grab info from DC Metro site to create XML file?
I feel like this may be a trivial problem for most people but I'm new at doing all this, so any help would be much appreciated!
So I need to get the coordinates of all the DC metro stops from the website. I did some searching and what I figured out is that the site with all the stations provides you with the option to click on the name of the station, which then shows a map of where the station is located. When you click on the map, you are directed to a google maps page where the coordinates are shown in the search box. I also noticed that the URL contains the coordinates as well.
From the research I did, it looks like it's possible to parse through the source code of the original DC metro website that holds all of the stations, go through each link to the stations, and then parse through the source code of each station's individual website to grab the coordinates and the name of the station. Once that is retrieved, it can be stored into an XML file. I wanted to make the XML look something like:
<stations> <station> <name>Ballston-MU</name> <lat>38.882071</lat> <long>-77.111845</long> </station> <station> <name>Addison Road</name> <lat>38.886713</lat> <long>-76.893592</long> ... </stations>
Sorry I know this is super long!!!
Just in case anyone was wondering, I did what user thg435 said and used the DC metro's own API. Just registered, got an API key, and used the URL they gave to get the XML file with all the info needed! :)
This was the URL (gotta insert your own custom API key to make it work): http://api.wmata.com/StationPrediction.svc/GetPrediction/A10?api_key=YOUR_API_KEY