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?
views:
11answers:
2@Eric: this is wrong. Check my answer for explanation.
Alejandro
2010-08-26 14:30:40
+1
A:
XPath expression that selects all non-empty
table:table-cell
children
In Xpath 1.0
table:table-cell[node()]
Note: This element is not empty:
<table:table-cell>Something</table:table-cell>
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
Alejandro
2010-08-26 14:29:42
Oh right. In my situation, the distinction didn't actually matter, but thanks for the explaination. Would `table:table-cell[count(node()) > 0]` be equivalent?
Eric
2010-09-01 21:12:48
@Eric: Yes. That expression is equivalent but much more verbose. It's important to note that non empty node set's boolean value is true.
Alejandro
2010-09-01 22:57:29