XPath Node Types

XPath 1.0 provides seven node types that are described in this section. Each node type corresponds to a part of the source XML document. Remember that two parts of the source XML document—the XML declaration, if present, and the DOCTYPE declaration—cannot be represented in XPath.

XPath is also unable to express an external parsed entity. If you want to address parts of such an entity, it is necessary to use XPointer.

Root Node

All XML documents that are well-formed have a single root node. The root node corresponds broadly to the document entity in XML 1.0 and is not visible within the code of the XML document.

A root node has no parent node or ancestor node. The root node has no name.

Element Nodes

Element nodes are the XPath ...

Get Special Edition Using XML, Second Edition 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.