views:

268

answers:

1

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"????

+2  A: 

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/

Torbjörn Gyllebring
Worked a charm once the NameSpaceManager was added. Thanks
Nick Allen - Tungle139