May 28, 2021 XPath
We'll use this XML document in the following example:
The axis defines the set of nodes relative to the current node.
The name of the axis | Results |
---|---|
ancestor | Select all ancestors (parent, grandfather, etc.) of the current node. |
ancestor-or-self | Select all ancestors of the current node (parent, grandfather, etc.) and the current node itself. |
attribute | Select all the properties of the current node. |
child | Select all child elements of the current node. |
descendant | Select all descendant elements (children, grandchildren, etc.) of the current node. |
descendant-or-self | Select all descendant elements (children, grandchildren, etc.) of the current node, as well as the current node itself. |
following | Select all nodes after the end label of the current node in the document. |
namespace | Select all namespace nodes for the current node. |
parent | Select the parent of the current node. |
preceding | Select all nodes before the start label of the current node in the document. |
preceding-sibling | Select all peer nodes before the current node. |
self | Select the current node. |
In the next section, we'll cover the XPath operator.