Yahoo GeoPlanet& XPathNavigator C#
-
02-07-2019 - |
题
我使用 HttpWebRequest
从Yahoo GeoPlanet Web服务返回XML数据。
我正在使用
加载XMLXPathDocument 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的教程/
不隶属于 StackOverflow