0

I'm 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 error on : For Each xmlLocation In objXMLDoc.documentElement.selectNodes("location") ,it says its not a method. Any insight? thanks in advanced.

4

1 回答 1

2

你必须使用 objXMLDoc.responsexml 而不是 objXMLDoc

像这样:

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
于 2013-06-25T12:12:18.463 回答