【问题标题】:Yahoo GeoPlanet & XPathNavigator C#雅虎 GeoPlanet 和 XPathNavigator C#
【发布时间】:2008-09-26 19:24:30
【问题描述】:

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

【问题讨论】:

    标签: c# web-services xpath yahoo


    【解决方案1】:

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

    【讨论】:

    • 在添加 NameSpaceManager 后发挥了作用。谢谢
    猜你喜欢
    • 2010-11-14
    • 1970-01-01
    • 1970-01-01
    • 2018-11-25
    • 1970-01-01
    • 2015-01-23
    • 1970-01-01
    • 2015-03-03
    • 1970-01-01
    相关资源
    最近更新 更多