Beginning XML Databases (Wrox Beginning Guides)

XPath is a language used for finding data in XML documents by parsing (scanning) those XML documents for specific values. XPath performs parsing of XML documents by applying an expression to the text of an XML document. The effective result is that an XPath expression allows navigation through XML document elements and attributes, retrieving items and values that match the expression passed into the XML document by XPath.

XPath performs a number of tasks :

Three logical models have been developed by the W3C for representation of XML documents. These are the XML Document Object Model (XML DOM), XPath, and XML Infoset (XML Information Set). The XML DOM in Chapter 2 is generally relatively slow with respect to performance when compared with XPath. XML Infoset ( http://www.w3.org/TR/xml-infoset ) will not be covered in this book in favor of the more up-to-date XPath 2.0 and XQuery 1.0.

Absolute and Relative Paths

In its simplest form, an XPath expression forms an absolute or a relative path. An absolute path has a starting forward slash (/), and a relative path does not. An absolute path searches an XML document from the precise path specified. A relative path searches relatively (possibly within an XML document not starting at the root node) from wherever specified. So, an absolute path searching from the root node looks something like this:

/root/nodeA/nodeB

And a relative path looks something like this:

nodeA/nodeB

Категории