Yahoo GeoPlanet& XPathNavigator C#

时间:2008-09-26 19:24:31

标签: c# web-services xpath yahoo

我使用HttpWebRequest从Yahoo GeoPlanet Web服务返回XML数据。

我正在使用

加载XML
XPathDocument doc = new XPathDocument(HttpWebResponse.GetResponseStream())

接下来:

XPathNavigator nav = doc.CreateNavigator();

如果我nav.Select("places");nav.Select("/places");nav.Select("//places");,则不会返回任何内容!

但如果我nav.select("/*");,我会得到节点,并且node.Name会返回places吗?

1 个答案:

答案 0 :(得分:2)

我对Yahoo数据的格式一无所知但我知道C#和XPath最常见的错误是忘记将相关的命名空间添加到“NamespaceManager”看看http://mydotnet.wordpress.com/2008/05/29/worlds-smallest-xml-xpath-tutorial/