我使用 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

有帮助吗?

解决方案

我对Yahoo数据的格式一无所知,但我知道C#和XPath最常见的错误是忘记将相关的命名空间添加到“NamespaceManager”中。看看这里 http://mydotnet.wordpress的.com / 2008/05 /第29 /世界-最小-XML的XPath的教程/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top