XPath

The XML Path Language (XPath) also models an XML document as a set of nodes. However, the hierarchy of nodes in the XPath representation of an XML document differs in several respects from the DOM representation.

XPath uses a path syntax to express the hierarchy of the content in an XML document. XPath bears similarities to the paths—hence the name XML Path Language—used to express the hierarchy of the file system on your computer.

The root node of an XPath document, which is equivalent to the document entity, is expressed as a single forward slash character (/). Nodes can then be accessed relative to the root node. For example, the document element of a document with a document element called myDocumentElement can be accessed using path ...

Get Sams Teach Yourself XML in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.