troubleshooting Question

Retrieve values from XML response to Google Maps

Avatar of Dale Fye
Dale FyeFlag for United States of America asked on
XML
2 Comments1 Solution115 ViewsLast Modified:
I'm pulling data from the Google Map API and it returns an XML response which looks like:
<DistanceMatrixResponse>
 <status>OK</status>
 <origin_address>Grafton, VA 23692, USA</origin_address>
 <destination_address>Yorktown, VA 23690, USA</destination_address>
 <row>
  <element>
   <status>OK</status>
   <duration>
    <value>556</value>
    <text>9 mins</text>
   </duration>
   <distance>
    <value>9779</value>
    <text>9.8 km</text>
   </distance>
  </element>
 </row>
</DistanceMatrixResponse>
I would like to extract the duration/text and distance/text values from this XML but the code found is using is not returning those values
    Dim domResponse As DOMDocument60
    Set domResponse = New DOMDocument60
    domResponse.loadXML objXMLHTTP.responseText
    
    Dim ixnStatus As Variant
    Set ixnStatus = domResponse.selectSingleNode("//status")
    
    If ixnStatus.Text = "OK" Then
        Dim ixnDistance, ixnDuration
        Set ixnDistance = domResponse.selectSingleNode("/DistanceMatrixResponse/row/element/distance/text")
Debug.Print ixnDistance
        Set ixnDuration = domResponse.selectSingleNode("/DistanceMatrixResponse/row/element/duration/text")
Debug.Print ixnDuration
    End If
and actually raises an error (#438          Object doesn't support this property or method) on line 11
I'm sure this is just a matter of getting the "SelectSingleNode" argument correct, but I have played with just about every combination of nodes names and cannot get this right.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros