Query XML DOM Nodes (Visual Basic)
MSXML provides two DOM methods that allow you to query a node or a set of nodes in an XML DOM object: SelectNodes
and SelectSingleNode
. You specify the node or nodes of interest in an XPath expression, which is taken as the input to these methods.
In this demonstration, we assume that you have some understanding of XPath expressions.
This project uses the following files.
Component | Description |
---|---|
Source: queryNodes.frm | This Visual Basic source file selects both a single node and a node-set from a DOM object. |
Resource: stocks.xml | An XML data file. |
Output | When you build and run the queryNodes project, you should get this output. |
To create the DynamDOMProj Visual Basic Project
Create a Visual Basic project and set a reference to MSXML 5.0 for Microsoft Office Applications. For detailed instructions on how to do this, see Set Up My Visual Basic Project.
Name the project DynamDOMProj.
Next, well add the source code for this project.