Search code examples
c#web-servicesxpathyahoo

Yahoo GeoPlanet & XPathNavigator C#


I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest.

I am loading the XML using

XPathDocument doc = new XPathDocument(HttpWebResponse.GetResponseStream())

Next comes:

XPathNavigator nav = doc.CreateNavigator();

If I do nav.Select("places"); or nav.Select("/places"); or nav.Select("//places");, nothing gets returned!

But if I do nav.select("/*");, I get the node and doing node.Name returns places?


Solution

  • I know nothing about the format of the Yahoo data but I do know that the most common misstake with C# and XPath is forgetting to add the relevant namespaces to your "NamespaceManager" have a look here http://mydotnet.wordpress.com/2008/05/29/worlds-smallest-xml-xpath-tutorial/