System.Xml.XPath
System.XML.XPath.XPathDocument
Introduced in .NET 2.0
System.XML.Xpath.XPathDocument
Read-only
optimised for Xpath queries
This is the preferred method when using XSLT transformations
System.XML.XPath.XPathNavigator
System.XML.XPath.XPathNavigator
To access any data in an XPathDocument you must create an XPathNavigator.
The XPathDocument is similar to the XMLDocument class however it doesn't build a tree of XML nodes in memory but processes them one node at a time.
The main purpose of the XPathDocument class is to perform Xpath queries and XSL transformations
This is read-only and does not support the W3C XML DOM functionality making it leaner and much faster.
An XPathNavigator must be created over the top in order to access the content and this class provides no read support directly.
There is no Load method because you create your XPathDocument by specifying the source in the constructor.
Dim objXPathNavigator As System.XML.Xpath.XPathNavigator
objXPathNavigator = objXPathDocument.CreateNavigator
MoveTo -
MoveToFirstChild - moves to the first child node of the current node.
MoveToFirstAttribute - moves to the first attribute of the current node.
MoveToAttribute - moves to the attribute with the matching local name
MoveToNext - moves to the next child node of the current node.
SelectSingleNode - selects a single node using a given Xpath.
There is a lof of confusion over when to use an element and when to use an attribute in XML so you will probably come across all kinds of data representation.
This makes is particularly useful to know exactly how to select the data you want.
| ./element_name | all "element_name" elements within the current context |
| element_name | same as above |
| one.two | all "one.two" elements within the current context |
| /document_element | the document element "document_element" of this document |
| //element_name | all "element_name" elements in this document |
| element_name[document_element/@attribute1=@attribute2] | all "element_name" elements whose "attribute2" attribute is equal to the "attribute1" attribute of the "document_element" at the root of the document |
| element_name1/element_name2 | all "element_name2" elements that are children of an "element_name1" element |
| .//element_name | all "element_name" elements one or more levels deep in the current context |
| ./element_name all "element_name" elements within the current context |
| element_name same as above |
| one.two all "one.two" elements within the current context |
| /document_element the document element "document_element" of this document |
| //element_name all "element_name" elements in this document |
| element_name[document_element/@attribute1=@attribute2] all "element_name" elements whose "attribute2" attribute is equal to the "attribute1" attribute of the "document_element" at the root of the document |
| element_name1/element_name2 all "element_name2" elements that are children of an "element_name1" element |
| .//element_name all "element_name" elements one or more levels deep in the current context |
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrev