Abbreviated Syntax

Contact Us or call 1-877-932-8228
Abbreviated Syntax

Abbreviated Syntax

The XPath syntax can sometimes be lengthy. Thankfully, there is an abbreviated syntax that is much more commonly used. The table below shows some of these abbreviations.

Abbreviated Syntax
Axis Description
child::
. self::node()
.. parent::node()
@ attribute::
.// ./descendant-or-self::node()/
// descendant-or-self::node()/
* all child elements of the context node
@* all attributes of the context node
[n] [position() = n]

The child:: axis is the default axis, so it can go unnamed; hence, the empty cell in the table above.

Examples of Abbreviated Syntax
Long Form Abbreviated Syntax
child::firstname firstname
child::* *
child::text() text()
attribute::name @name
attribute::* @*
descendant-or-self::firstname .//firstname
child::chapter/descendant::para chapter//para
child::*/child::para */para
/descendant::para //para
child::para[position()=1] para[1]
child::para[attribute::type="warning"] para[@type="warning"]
child::*[self::chapter or self::appendix] *[name()='chapter' or name()='appendix']
Next