Source: LoadXMLFile.frm

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Developer's Guide

Source: LoadXMLFile.frm

The following code snippet loads an XML file from the current directory into an XML DOM object. In Visual Basic, the current directory is represented by App.Path property.

Visual Basic Source File (LoadXMLFile.frm)

Private Sub Form_Load()
    Dim doc As New DOMDocument50
    doc.async = False
    doc.validateOnParse = False
    doc.resolveExternals = False
    
    Path = App.Path + "\test.xml"
    doc.Load Path
    MsgBox "doc: " + doc.xml
End Sub

To add LoadXMLFile.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, we'll add the resource file, test.xml.