【问题标题】:XPathSelectElement always return nullXPathSelectElement 总是返回 null
【发布时间】:2013-10-07 07:46:23
【问题描述】:
string xml = @"<vehicle>   <cars>     <car>tet</car>    </cars> </vehicle>";
XElement x = XElement.Parse(xml);
var node = x.XPathSelectElement("//vehicle/cars");

为什么节点总是为空?

【问题讨论】:

    标签: c# xml xpath linq-to-xml


    【解决方案1】:

    XPath 应该是

    var node = x.XPathSelectElement("cars");
    

    输出:

    <cars>
      <car>tet</car>
    </cars>
    

    【讨论】:

    • 这也返回 null
    • @HennovanRensburg:使用汽车
    猜你喜欢
    • 1970-01-01
    • 2014-03-04
    • 2016-11-02
    • 2014-05-06
    • 2012-06-05
    • 2014-05-30
    • 2014-02-23
    • 2017-10-12
    相关资源
    最近更新 更多