XPath Abbreviations Quick Reference

The
child axis is assumed. For example, the following two XPath expressions both return the
para children of
chapter children of the context node:

chapter/para
child::chapter/child::para

@

The
attribute axis. For example, the following two XPath expressions both return
para children of the context node that have
type attributes with a value of
warning:

para[@type="warning"]
child::para[attribute::type="warning"]

//

The
descendant-or-self axis. For example, the following two XPath expressions both return all
para descendants of the context node:

//para
/descendant-or-self::node()/child::para

However, it is important to note that the following two expressions are
not equivalent:

/descendant::para[1]
//para[1]

The first expression selects the first
para element that is a descendant of the context node. The second expression selects each
para descendant that is the first
para child of its parent.

.

A single dot is the abbreviation for
self::node(). This selects the context node. For example, the following two XPath expressions both return all
para descendants of the context node:

.//para
self::node()/descendant-or-self::node()/child::para

..

A double dot is the abbreviation for
parent::node(). This selects the parent of the context node. For example, the following two XPath expressions both return the
title children of the parent of the context node: