We have now learned the basics of selecting content in reference to the current page, and know the very basics of how it is used. Now we can cover a few additional commands, and explain how they work.
XPATH works on the premise of Axes, which is how the data relates to the current node. There are several Axis listed below with graphic depictions of the results. Please note the numbers, as those are the order in which the results would be returned.
The following picture from Crane Softwrights demonstrates the
axes graphically.
Self Axis
While it is rarely used, the self axis actually returns the node in reference.
$currentPage/self::node
Child Axis
We mentioned the child axis earlier, and actually used its shortcut right off. The child axis select the nodes immediately below the node in reference. While the verbose method is rarely used, it is here for reference.
$currentPage/child::node
$currentPage/node
Parent Axis
The parent axis allows us to see the node immediately above the node in reference.
$currentPage/parent::node
$currentPage/../
Descendant Axis
Next we have descendant. The descendant axis retrieves all nodes below the node in reference no matter the depth.
$currentPage/descendant::node
$currentPage//node
Descendant-or-self Axis
The descendant-or-self axis returns all nodes below the current node, but also returns the node in reference to the command.
$currentPage/descendant-or-self::node
Ancestor Axis
The ancestor axis selects all nodes that are ancestors, or the parent, and the parent's parent, and so on, to the node in reference.
$currentPage/ancestor::node
Ancestor-or-self Axis
The ancestor-or-self axis selects all nodes that are ancestors, or the parent, and the parent's parent, and so on, including the node in reference.
$currentPage/ancestor-or-self::node
Preceding Axis
The preceding axis selects all nodes no matter the depth, that are located on parent-level and who are also located before (preceding) its parent of the node in reference.
$currentPage/preceding::node
Preceding-sibling Axis
The preceding axis selects all nodes that are located on the same level who are also located before (preceding) the node in reference.
$currentPage/preceding-sibling::node
Following Axis
The preceding axis selects all nodes no matter the depth, that are
located on parent-level and who are also located after (following) its
parent of the node in reference.
$currentPage/following::node
Following-sibling Axis
The preceding axis selects all nodes that are located on the same
level who are also located before (preceding) the node in reference.
$currentPage/following-sibling::node
Note: I have copied the original book from Casey Neehouse from the books section of umbraco.org