XML technologies / XML / Python & XML / Querying XML with XPath / XPath at a glance

(Excerpt from "Python & XML" by Christopher A. Jones & Fred L. Drake, Jr.)

XPath 1.0 is a W3C recommendation (Note from the data2type editors: There is now XPath 3.0, as of February 2015). XPath provides access to parts of an XML document through XPath expressions. The specification defines a concrete expression syntax and a well-defined meaning when expressions are interpreted. When an XPath expression is processed by a DOM, the matching nodes are returned to the caller. XPath expressions target a particular node or a group of nodes in an XML document. The result can take four different forms:

In XPath the term context refers to the location in the document where the XPath expression is applied. You can start at the document element (the root element) or at any element derived from it. XPath can report the current context node, which represents the current position in the document. A pair of integers can specify the context position and size. The context may also contain variables, functions and a namespace relevant to the current position.

  

 

 

 

back to top