Home > Positioning > Subjects > XPath > The navigation model

The navigation model

XPath’s substance is a small, composable model for saying where in a tree.

Location paths and steps

A path is a sequence of steps separated by /; an absolute path begins at the root (/a/b), a relative one at a context node (b/c). Each step has three parts:

The compact syntax (/catalog/book/title) is shorthand for the full axis form (/child::catalog/child::book/child::title); both denote the same navigation.

What a path yields

XPath 1.0 evaluates to one of four types — a node-set, a string, a number, or a boolean. XPath 2.0 onward generalised node-sets to sequences with a richer type system, aligning with XQuery and turning XPath from a selector into a small functional query language.

The lasting contribution is the axis model: a vocabulary for navigating hierarchy in any direction — which is why XPath’s idea outlived XML and reappears wherever structured data must be addressed.

Sources