xpath:获取没有 X 祖先的节点 [英] xpath: get nodes that do not have an X ancestor

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

问题描述

我想要一个 xml 文档的所有节点,它们不是节点 X 的后代.

I want all nodes of an xml document that are not descendants of nodes X.

(我的实际问题有点复杂,但我现在被困在不是后代"部分).

(My actual problem is a little more complex, but I'm stuck with the "are not descendants" part right now).

推荐答案

如果将不是后代"翻译为没有祖先",则会得到表达式 ///*[not(ancestor::X)].这将返回文档中的所有节点,这些节点不是名为X"的节点的后代.

If you translate "are not descendants" to "have no ancestor", you get the expression //*[not(ancestor::X)]. This will return all nodes in a document, which are not descendants of nodes named "X".

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

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