to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

XPath: Location paths

XPath is a declarative language for:

The central construct is the location path, which is a sequence of location steps separated by /, e.g.:
  child::section[position()<6] / descendant::cite / attribute::href

selects all href attributes in cite elements in the first 5 sections of an article document.

A context consists of:

Initial context: defined externally (e.g. by XPointer, XSLT, or XQuery).
Location paths can be prefixed with / to use the document root as initial context node!

Note: in the XPath data model, the XML document tree has a special root node above the root element.

There is a strong analogy to directory paths (in UNIX). As an example, the directory path /*/d/*.txt selects a set of files, and the location path /*/d/*[@ext="txt"] select a set of XML elements.

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next