选择根并从 XPath 中的选择中排除节点

问题描述 投票:0回答:1

考虑以下文档:

<root>
  <a></a>
  <b></b>
  <c></c>
  <d></d>
  <e></e>
</root>

我想选择

root
及其除
e
之外的所有节点。很确定我需要使用
not(name() = 'e')
not(self::e)
。例如
//root/*[not(name() = 'e']
但我不包括
root

xpath
1个回答
0
投票

快到了,只需使用:

//*[not(name() = 'e']
© www.soinside.com 2019 - 2024. All rights reserved.