我正在尝试从谷歌地图xml请求并保存在DDBB中的lat和lng,我正在使用的代码如下:
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
我一直收到错误: 对于每个xmlLocation在objXMLDoc.documentElement.selectNodes(“location”)中 ,它说它不是一种方法。 任何见解?谢谢你提前。
答案 0 :(得分: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