I'm trying to parse XML in Classic ASP.
I tried different examples, they suppose to work but I can't
Can anyone give me a hand? For example, if I want to get value for "lat" and "formatted_address" how can I do it?
Below is the XML that I get from the link above
<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>
Initiate the XML document in classic ASP, once you done that try using the XPath
Set docXML = CreateObject( "Microsoft.XMLDOM" )
docXML.async = False
docXML.loadXML( myXMLText )
for getting the lat
docXML.documentElement.selectSingleNode( "/GeocodeResponse/result/geometry/location/lat" )
and
docXML.documentElement.selectSingleNode( "/GeocodeResponse/result/formatted_address" )
for getting the formatted address.