Table of Contents
Because XML documents are tree-structured, we must be able to designate nodes in their trees either absolutely (i.e. starting from the root) or relatively to a given node. An XPath expression refers to either a single node or to a set of nodes in the document tree. In this report, we use the XPath 2.0 syntax [17], standardized in 2006 and implemented by many XSLT processors. It is more powerful and better principled than the previous XPath 1.0 standard. Therefore make sure to run the examples of this document with a processor meeting both XPath 2.0 and XSLT 2.0 standards. XPath 2.0 has become a full-blown programming language, as can be seen from the 400 pages of chapters 7 thru 13 of the book of Michael Kay [27]. Thus we only give an overview in these few pages.
In 2014, the XPath 3.0 recommandation was published with many new features, such as dynamic function call, mapping operators and a string concatenation operator, but these features are not used in this simple tutorial.
XPath is an expression language designed primarily for accessing nodes in an XML document. It cannot modify the XML document, nor does it permit the creation of new nodes in a document. An XPath expression has one of the following types of values:
atomic values of any XML Schema type (see Section 3.2) either simple ones such as integers, boolean, dates, URI or even user-defined ones through a Schema.
sequence of atomic values and trees, but not of sequences (sequences cannot be nested)