XPath is a XML language used for accesing nodes and node-sets of a document.

XPath axes

Axes names Description
ancestor Selects all ancestors of current node.
ancestor-or-self Selects all ancestors of current node and node itself.
attribute Selects all attributes of current node.
child Selects all children of current node.
descendant Selects all descendants of current node.
descendant-or-self Selects all descendants of current node and node itself.
following Selects everything in the document after the closing tag of current node.
following-sibling Selects all siblings after the current node.
namespace Selects all namespaces nodes of current node.
parent Selects parent of current node.
preceding Selects all nodes that appear before the current node except attribute and namespace node.
preceding-sibling Selects all siblings before current node.
self Selects current node.

Node types

Node types Description
Attribute Presents an attribute of an element.
Comment Presents a comment (all but those inside DTD's).
Element Presents an element of a document.
Namespace Presents a namespace of an element.
PI Presents a processing instruction (all but those inside DTD's).
Root Presents the first node of a document.
Text Presents a text node of a document (including CDATA).

Elements accessing

Expression Description
nodename Selects all nodes with that name.
/ Selects from root node.
// Selects from current node that matches the selection.
. Selects current node.
.. Selects current node's parent.
| Selects multiple paths.
predicates Select specific node with given value.
wildcards Select nodes regardless of their name.

Attributes accessing

Expression Description
@ Selects attributes with given value.
predicates Select specific node with given value.
wildcards Select nodes regardless of their name.