tags:

views:

11

answers:

2

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?

+1  A: 

Got it:

table:table-cell[count(*) > 0]

Eric
@Eric: this is wrong. Check my answer for explanation.
Alejandro
+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
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
@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