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.


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext