Link to home
Start Free TrialLog in
Avatar of sherbug1015
sherbug1015Flag for United States of America

asked on


I have a web service that is returning this:

<?xml version="1.0" encoding="utf-16"?>
<GeocodeInfo xmlns:xsi="" xmlns:xsd="">
  <Latitude xmlns="">42.0903</Latitude>
  <Longitude xmlns="">-71.423011</Longitude>
  <AddressID xmlns="">27195</AddressID>

I am trying to extract the latitude like this but I am not getting any value

sLatitude = xdoc.SelectNodes("/Latitude")

Can someone help me with this.

Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
a better way is to use a namespace mannager

XmlNamespaceManager manager = new XmlNamespaceManager(xdoc.NameTable);
manager.AddNamespace("tmp", "");

sLatitude = xdoc.SelectNodes("//tmp:Latitude")

this way you bind the "tmp:" prefix to the tempuri namespace first
and then you use the prefix in teh XPath