XPATH 1.0 : match not empty elements

折月煮酒 提交于 2021-01-28 04:52:54

问题


I need to match elements that contain neither PCDATA nor child elements.

I tried this:

.//myelem[count(nodes())=0]

but nodes() is unknown in XPATH 1.0.

What is the most concise way that you know of to do this in XPATH 1.0 ?


回答1:


You were close - it is node(), not nodes():

.//myelem[count(node()) = 0]

or, more idiomatically:

.//myelem[not(node())]


来源:https://stackoverflow.com/questions/1914085/xpath-1-0-match-not-empty-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!