XPath expressions can select nodes using a number
of different axis specifiers.
Each axis describes a different set of nodes relative
to the context node, a different direction. For example, using the
child axis
allows you to select only nodes that are children
of the context node. The child
axis is the default axis.
To select nodes from a specific axis, use the syntax
where
axis::ee is any XPath expression.
For example, ancestor::cluster
would select all <cluster>
elements that are ancestors of the context node.
Here are the axis specifiers:
child::Selects children of the context node. Attribute
nodes are not included; use the
attribute::
axis to get attribute nodes.
parent::
Selects only the parent node, if there is one. Can
be abbreviated as “../”
self::
Selects only the context node. This can be
abbreviated as “./”.
attribute::
Selects only the attributes of the context node.
Can be abbreviated as “@”.
ancestor::Refers to all ancestors of the context node: its parent, its parent's parent, and so on up to and including the document node.
ancestor-or-self::Refers to the context node and its ancestors.
descendant::Refers to the descendants of the context node: its children, their children, and so on up to and including the leaves of the tree.
descendant-or-self::Refers to the context node and its descendants.
preceding-sibling::Refers to all children of the context node's parent that occur before the context node.
following-sibling::Refers to all children of the context node's parent that occur after the context node.
preceding::All nodes that precede the context node in the whole document. This set does not include the context node's descendants or attributes.
following::All nodes that follow the context node in the whole document. This set does not include the context node's descendants or attributes.
