Axes

The axis is a filter. It filters based on the relationship between the nodes selected to the context node. It is based on the position of the node in the tree.

ancestor

Selects the ancestors of the current context.

//td[.="Bravo"]/ancestor::tr

ancestor-or-self

Selects the ancestors and includes the current context node.

//td[.="Bravo"]/ancestor-or-self::td

attribute

The attribute axis selects the attributes of the nodes in the current context.

/table/tr/attribute::class

child

The child axis selects the immediate child nodes of the current context.

/table/tr/child::td

descendant

The descendant axis selects descendant nodes of the current context.

/table/tr/descendant::table

descendant-or-self

The descendant-or-self axis selects the nodes which are descendants of the current context, including nodes from the current context.

/table/tr/td/descendant-or-self::td

following

The following axis selects nodes that follows after the current context. It does not include descendants, attribute nodes and namespace nodes.

//td[.="Bravo"]/following::*

following-sibling

The following-sibling axis selects siblings which follows after the current context. It excludes children nodes that appear before the current context.

/table/tr[2]/following-sibling::*

namespace

The namespace axis selects the namespace node of the current context.

/*/namespace::*[name()='']

parent

The parent axis selects the parent of the current context. The parent is the immediate node preceding the current context. It is different from ancestors which includes nodes at multiple levels preceding the current context.

//td[.="Bravo"]/parent::*

preceding

The preceding axis selects elements that precedes the current context. It does not include ancestors, attribute nodes and namespace nodes.

//td[.="Bravo"]/preceding::*

preceding-sibling

The preceding-sibling axis selects siblings which precedes the current context. It excludes children nodes that appear after the current context.

/table/tr[2]/preceding-sibling::*

self

The self axis selects the current context node.

/table/tr[2]/self::*