Reputation: 13659
Can someone please explain what the below Xpath expressions mean?
//node()[not(*)][not(normalize-space())]
//node()[not(*)][not(normalize-space())][not(boolean(@Key))]
//node()[not(text())]
I understand //node()
means any node, but not sure with the following expressions.
Upvotes: 1
Views: 93
Reputation: 9627
Updated (thanks to @Michael Kay comment)
First one:
//node()
all nodes in the document (including text, comment and processing instruction but not attributes)
[not(*)]
which does not have any child element nodes
[not(normalize-space())]
which does not have any text content (beside of whitespace).
Second one: Same as first one but additional:
[not(boolean(@Key))]
the node has no attribute Key
Update:
For the third one have a look to e.g. this
In your example this will also ignore nodes with any text content (even white space)
Upvotes: 0
Reputation: 163625
//node()[not(*)][not(normalize-space())]
All element, text, comment, and processing-instruction nodes, anywhere in the document, that do not have a child element node and whose string value is either empty or consists entirely of whitespace
//node()[not(*)][not(normalize-space())][not(boolean(@Key))]
As above, with the extra condition that there is no @Key attribute. The last predicate is badly written: it could be shortened to [not(@Key)]
without changing its meaning.
//node()[not(text())]
All element, text, comment, and processing-instruction nodes, anywhere in the document, that do not have a child text node.
Upvotes: 4