Source: InstantiateDOM.frm
In this application, we create two XML DOM objects, and load an XML string into each object.
Visual Basic Source File (InstantiateDOM.frm)
Private Sub Form_Load()
' Instantiate an object at run time.
Dim dom1
Set dom1 = New DOMDocument60
dom1.async = False
dom1.resolveExternals = False
dom1.loadXML "<a>A</a>"
' Instantiate an object at compile time.
Dim dom2 As New DOMDocument60
dom2.async = False
dom2.resolveExternals = False
dom2.loadXML "<b>B</b>"
' Display the content of both objects.
MsgBox "dom1: " + dom1.xml + vbNewLine + "dom2: " + dom2.xml
End Sub
To add InstantiateDOM.frm to the project
- Copy the code listing above. Paste it into the Visual Basic code editor as the form_load subroutine, replacing any code fragments that are already there.
Next, run the project. The result should be the output shown in the following topic.