XPath Axes
An XPath expression can select the nodes relative to the current node.
Axis | Description | Example |
---|---|---|
ancestor | All ancestor nodes of the current node | /table/tbody/tr/td/ancestor::tr |
ancestor-or-self | the current node and it's ancestors | //tr/ancestor-or-self::tr |
attribute | the attributes of the current node | /item[attribute::price = '100'] |
child | the children of the current node | /item/child::* |
descendant | the descendants of the current node | /item/descendant::* |
descendant-or-self | the descendants and the current node | /item/descendant-or-self::* |
following | all the nodes that exist after the current node, not necessarily a sibling | /item[@id = '123']/following::* |
following-sibling | the siblings of the current node sharing the same parent and the same level. | /item[@id = '123']/following-sibling::* |
namespace | the namespace of the current node | /*/namespace::* |
parent | the parent of the current node | /item/meta/parent::* |
preceding | all the nodes that exist before the current node, not necessarily a sibling | /item[@id = '123']/preceding::* |
preceding-sibling | the siblings of the current node sharing the same parent and the same level. | /item[@id = '123']/preceding-sibling::* |
self | the current node | /item[@id = '123']/self::item |