'Asp code for getting lat/lng from google XML
I am trying to request and save in a DDBB the lat and lng from google maps xml, the code I'm using is the following :
url = "http://maps.googleapis.com/maps/api/geocode/xml?address="&sensor=false"
response.write "URL... : " & url &"</br>"
Set objXMLDoc = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
objXMLDoc.setTimeouts 30000, 30000, 30000, 30000
objXMLDoc.Open "GET", url, False
objXMLDoc.send()
Dim xmlLocation
For Each xmlLocation In objXMLDoc.documentElement.selectNodes("location")
lat = xmlLocation.selectSingleNode("lat").text
lng = xmlLocation.selectSingleNode("lng").text
Response.Write Server.HTMLEncode(lat) & " "
Response.Write Server.HTMLEncode(lng) & "<br>"
Next
I keep getting an error on:
For Each xmlLocation In objXMLDoc.documentElement.selectNodes("location")
It says its not a method.
Any insight?
Solution 1:[1]
You have to use objXMLDoc.responsexml instead of objXMLDoc like so:
response.write "<hr>"
response.write objXMLDoc.responsexml.selectSingleNode("GeocodeResponse/result/geometry/location/lat").text
response.write "<hr>"
response.write objXMLDoc.responsexml.selectSingleNode("GeocodeResponse/result/geometry/location/lng").text
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vinzee |
