【问题标题】:How do I find XML nodes which don't contain an attribute using XPath?如何使用 XPath 查找不包含属性的 XML 节点?
【发布时间】:2013-07-17 16:01:06
【问题描述】:

我在 VB.net 中使用带有以下 XML 的 XPath:

<bookstore>

<book>
  <title lang="eng">Harry Potter</title>
  <price>29.99</price>
</book>

<book>
  <title lang="eng">Learning XML</title>
  <price>39.95</price>
</book>

<book>
  <title>English-French Dictionary</title>
  <price>29.95</price>
</book>

</bookstore> 

根据this guide,很容易得到具有特定属性的节点列表。

//标题[@lang]
选择所有具有属性的标题元素 命名语言

但是你如何获得具有特定属性的节点列表呢? (例如上面的第三本书,它没有lang 属性。)

【问题讨论】:

    标签: xml vb.net xpath


    【解决方案1】:

    你可以使用:

    //title[not(@lang)]
    

    【讨论】:

      猜你喜欢
      • 2011-07-24
      • 1970-01-01
      • 1970-01-01
      • 2010-10-11
      • 1970-01-01
      • 2015-05-14
      • 2023-03-23
      • 1970-01-01
      • 2012-04-22
      相关资源
      最近更新 更多