Importing to XML Using the ImportXML Method

Use the ImportXML method to programmatically import an XML data file and/or schema file. The ImportXML method takes two arguments, as shown in Table 29-4.

Table 29-4: Arguments of the ImportXML method (in order of appearance)

Argument Type

Data Type

Description

DataSource (required)

String

Specifies the full path of the XML file to import.

ImportOptions (optional)

acImportXMLOption

Use one of the following constants:

Constant Value acAppendData 2 acStructureAndData 1 acStructureOnly 0

Specifies whether to import structure only (0), import structure and data (1) (default), or append data (2).

The following procedure will import the structure of the Extensions table from the EmpExtensions.xml file:

Sub Import_XMLFile()

Application.ImportXML DataSource:="c:\Learn_XML\EmpExtensions.xml", _ ImportOptions:=acStructureOnly

MsgBox "The import operation completed successfully."

End Sub

0 0

Post a comment