Reputation: 322
I'm trying to understand a piece of code I should manage. I found some html manipulation in which HtmlAgilityPack is used for some node selection. Someone knows the meaning of this xpath selector?
//table/*[not(self::tr or self::tbody)]
Upvotes: 3
Views: 352
Reputation: 60424
In English:
Select any element node (
*
) such that it is not itself atr
ortbody
([not(self::tr or self::tbody)]
) and that is the child of atable
element that could appear anywhere in the document (//table
).
It is equivalent to the following un-abbreviated expression
/descendant-or-self::node()/child::table/child::*[not(self::tr or self::tbody)]
Upvotes: 2
Reputation: 63378
self
is a handy way of referring to the name of the element node under consideration, without namespaces.
In this example, we will match any element which is a child of a table
, and is not a tr
or a tbody
.
Upvotes: 2