xpath: get nodes that do not have an X ancestor

后端 未结 2 2054
庸人自扰
庸人自扰 2021-02-01 01:28

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\" par

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 01:38

    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".

提交回复
热议问题