xpath The "self" axis


The self axis only contains the context node itself. The expression . is a shortcut for self::node() and always matches the context node. The . shortcut is useful for enumerating descendants of the context node. The following expressions are equivalent:


The self axis can be helpful in XPath 1.0 predicates. For example, to select all h1, h2, and h3 children of the context node:

*[self::h1 or self::h2 or self::h3]