XPath - Abbreviated Syntax

admin's picture
 
XPath Description
* selects all element children of the context node (child::*)
text()
selects all text node children of the context node
@name selects the name attribute of the context node (attribute::name)
@* selects all the attributes of the context node (attribute::*)
perm[1]
selects the first perm child of the context node
perm[last()]
selects the last perm child of the context node
../perm select the perm children of the parent of the context node (parent::name)
perm selects the perm element, child of the context node (child::perm)
//perm selects all the perm) descendants of the document root and thus selects all perm elements in the same document as the context node (descendant::perm
. selects the context node (self::node())
.. selects the parent of the context node (parent::node())
//permissions/perm[5]
selects the fifth perm of the permissions
../@attName
selects the attName attribute of the parent of the context node
perm[@type="admin"]
selects all perm children of the context node that have a type attribute with value admin
para[@type="admin"][5]
selects the fifth perm child of the context node that has a type attribute with value admin
para[5][@type="admin"]
selects the fifth perm child of the context node if that child has a type attribute with value admin