如何编写仅选择非空子项的 XPath 选择器? [英] How can I write an XPath selector that picks only non-empty children?

查看:21
本文介绍了如何编写仅选择非空子项的 XPath 选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个 XPath 表达式来选择当前元素的所有非空 table:table-cell 子元素.我该怎么做?

I want to write an XPath expression that selects all non-empty table:table-cell children of the current element. How do I do this?

推荐答案

选择所有的 XPath 表达式非空 table:table-cell 子项

在 Xpath 1.0 中

In Xpath 1.0

table:table-cell[node()]

注意:该元素不为空:

<table:table-cell>Something</table:table-cell>

但是表达式 table:table-cell[count(*) >0] 不选择它,因为它意味着:all table:table-cell chindren 至少有一个 element 孩子

But the expression table:table-cell[count(*) > 0] does not select it, because it means: all table:table-cell chindren having at least one element child

这篇关于如何编写仅选择非空子项的 XPath 选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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