缺少节点的xpath [英] xpath for missing node

查看:27
本文介绍了缺少节点的xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 xml:

<root>
  <node>
     <tag1/>
     <tag2/>
     <tag3/>
  </node>
  <node>
     <tag1/>
     <tag2/>
     <tag3/>
  </node>
  <node>
     <tag1/>
     <tag3/>
  </node>
</root>

如您所见,在第三个节点中,我缺少一个 tag2.是否有任何 xpath 我可以应用于 c# XmlDocument(通过 SelectNodes),它可以返回没有 tag2 节点的节点?

As you can see, in the 3rd node I have a missing tag2. Is there any xpath I can apply to a c# XmlDocument (via SelectNodes) that can return me the node that does not have the tag2 node?

推荐答案

试试下面的 xpath:

Try the following xpath:

/root/node[not(tag2)]

这篇关于缺少节点的xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆