Instantiate an XML DOM Object (Visual Basic)

 

There are two ways to instantiate an XML DOM object in Visual Basic. One way is to create the object at compile time, as follows:

Dim objXMLDoc As New DOMDocument30

You can also create the object at run time, as follows:

Dim objXMLDoc

Set objXMLDoc = New DOMDocument30

In this demonstration, we illustrate both ways of creating a XML DOM instance.

This tutorial uses or creates the following files:

File Description
Source: InstantiateDOM.frm Visual Basic source code.
Output Output from the application.

To create the InstantiateDOM Visual Basic Project

  1. 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.

  2. Name the project InstantiateDOMProj.

Next, add the source code for the InstantiateDOM project.