1

使用http://maps.googleapis.com/maps/api/geocode/xml?address=5555%20La%20Cienaga%20Blvd%20Los%20Angeles,%20CA&sensor=false

我正在尝试在经典 ASP 中解析 XML。

我尝试了不同的例子,他们认为可以工作,但我不能

谁能帮我一把?例如,如果我想获取“ lat ”和“ formatted_address ”的值,我该怎么做?

下面是我从上面的链接获得的 XML

<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>5555 La Cienega, Los Angeles, CA 90056, USA</formatted_address>
<address_component>
<long_name>5555</long_name>
<short_name>5555</short_name>
<type>street_number</type>
</address_component>
<address_component>
<long_name>La Cienega</long_name>
<short_name>La Cienega</short_name>
<type>route</type>
</address_component>
<address_component>
<long_name>Los Angeles</long_name>
<short_name>Los Angeles</short_name>
<type>locality</type>
<type>political</type>
</address_component>
<address_component>
<long_name>Los Angeles</long_name>
<short_name>Los Angeles</short_name>
<type>administrative_area_level_2</type>
<type>political</type>
</address_component>
<address_component>
<long_name>California</long_name>
<short_name>CA</short_name>
<type>administrative_area_level_1</type>
<type>political</type>
</address_component>
<address_component>
<long_name>United States</long_name>
<short_name>US</short_name>
<type>country</type>
<type>political</type>
</address_component>
<address_component>
<long_name>90056</long_name>
<short_name>90056</short_name>
<type>postal_code</type>
</address_component>
<geometry>
<location>
<lat>33.9978986</lat>
<lng>-118.3696586</lng>
</location>
<location_type>RANGE_INTERPOLATED</location_type>
<viewport>
<southwest>
<lat>33.9965523</lat>
<lng>-118.3709990</lng>
</southwest>
<northeast>
<lat>33.9992503</lat>
<lng>-118.3683010</lng>
</northeast>
</viewport>
<bounds>
<southwest>
<lat>33.9978986</lat>
<lng>-118.3696586</lng>
</southwest>
<northeast>
<lat>33.9979040</lat>
<lng>-118.3696414</lng>
</northeast>
</bounds>
</geometry>
<partial_match>true</partial_match>
</result>
</GeocodeResponse>
4

1 回答 1

1

在经典 ASP 中启动 XML 文档,完成后尝试使用 XPath

Set docXML = CreateObject( "Microsoft.XMLDOM" ) 
docXML.async = False 
docXML.loadXML( myXMLText )

为了获得纬度

docXML.documentElement.selectSingleNode( "/GeocodeResponse/result/geometry/location/lat" )

docXML.documentElement.selectSingleNode( "/GeocodeResponse/result/formatted_address" )

用于获取格式化的地址。

于 2013-02-20T09:25:24.253 回答