In my application, I'm converting from one web service to another. I get an XML response as an XmlDocument. I'm trying to get specific nodes in the document. I know there will only ever be one instance of the node I'm looking for. The previous implementer was able to get exactly what he wants with:
XmlNode node = xmlDoc.SelectSingleNode("//result/geometry/location/lat/text()");
I'm trying to do the same with my response, but always get null back. I know (vaguely) what his XML response looked like, and know mine. But I can't use his syntax. I get null no matter what. I'm using a more complex statement:
XmlNode xmlNode = xmlDoc.GetElementsByTagName("StatusDescription").Item(0);
But, as you can see, it's ugly. And--worse--whenever I try to go more than one node deep, I get null back:
XmlNode xmlNode = xmlDoc.GetElementsByTagName("/ResourceSets/ResourceSet").Item(0);
I've tried inserting and removing slashes in several places, but to no avail. The XML the previous implementer got back isn't anything special; it's just XML. But he can jump all over the place with ease.
Here's a snippet of his XML response:
<GeocodeResponse>
 <status>OK</status>
 <result>
  <geometry>
   <location>
    <lat>37.4217550</lat>
    <lng>-122.0846330</lng>
   </location>
  </geometry>
 </result>
</GeocodeResponse>
Here's a snippet of mine:
<Response xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <StatusCode>200</StatusCode>
  <StatusDescription>OK</StatusDescription>
  <ResourceSets>
    <ResourceSet>
      <EstimatedTotal>1</EstimatedTotal>
        <Resources>
          <Location>
              ...
          </Location>
        </Resources>
    </ResourceSet>
  </ResourceSets>
</Response>
Any idea how I can traverse the XML as easy as him?
 
    