Share via


Node Types Recognized with XPath Queries

The types of nodes recognized by an XPath implementation are not the same node types found in the Document Object Model (DOM). The XPath implementation recognizes the following ten distinct node types:

  • Root
  • Element
  • Attribute
  • Namespace
  • Text
  • ProcessingInstruction
  • Comment
  • SignificantWhitespace
  • Whitespace
  • All

These node types, enumerated by the XPathNodeType Enumeration, are based on the XPath data model, where the nodes are derived from the XML Information Set. The SignificantWhitespace, Whitespace, and All XPath node types are .NET extensions to the base node types describe in the XPath data model specification.

The attribute node type is used differently in XPath than it is in the DOM. In the XPath Data Model, the element has a set of attribute nodes related to it, and the element is the parent of each attribute node. However, in the DOM, the element node is the owner, not the parent. In both models, attribute and namespace nodes are not considered child nodes of the element. The namespace node type is an addition to the XPath data model, and is not a recognized DOM node type. To see how to navigate attribute and namespace nodes using XPathNavigator, see Attribute and Namespace Navigation using XPathNavigator. To see how to navigate the other node types, see Node Set Navigation using XPathNavigator.

See Also

XPathNavigator in the .NET Framework | Node Set Navigation Using XPath Queries | Attribute and Namespace Navigation Using XPathNavigator | Compile, Select, Evaluate, and Matches with XPath and XPathExpressions