XPath - Some Important Abbreviations

The most important abbreviation is that
child:: can be omitted from a location step. In effect,child is the default axis.For example, a location path
Data/username is short forchild::Data/child::username |
There is also an abbreviation for attributes:
attribute:: can be abbreviated to @ .For example, a location path
/*/*/*/*/*/*/*/perm[ @type="admin"] is short for/*/*/*/*/*/*/*/child::perm[attribute::type="admin"] ... and so selects
perm children with a type attribute with value equal to admin . |
// is short for /descendant-or-self::node()/ . For example,
1.)
//perm is short for/descendant-or-self::node()/child::perm ... and so will select any
perm element in the document (even a perm element that is a document element will be selected by //perm since the document element node is a child of the root node); 2.)
Data//perm is short for Data/descendant-or-self::node()/child::perm ... and so will select all p
erm descendants of Data children. |
For example,
../title is short for parent::node()/child::title ... and so will select the
title children of the parent of the context node
//getUserToken/usertoken/permissions/../usernameis short for
//getUserToken/usertoken/permissions/parent::node()/child::username
|