joined:Sept 30, 2009
I don't know if it is because I have a shaky foundation parsing XML or because the Google Geocode API was written by somebody drunk, but I am having a difficult time parsing their XML file and was hoping for some help. I'd like to think it was more of my shaky foundation rather than the drunk coder, but the XML seems strangely nested and because of this I'm having a hard time using online tutorials for parsing XML.
A sample XML file I'm working with:
var url = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=47.616483,-122.319164&sensor=false";
My script so far:
var xml = new XMLHttpRequest();
xml.open("GET", url, false);
If available, I'm trying to get the first Long Name for "neighborhood", "sublocality", "locality", and the first Short Name for "country".
I am not using jQuery and do not want to load a huge library for what I hope will be a simple task. If it makes a difference a JSON format is also available by changing xml to json.