Importing Data into an Existing XML

As you may have guessed, the Import method imports data from an XML file into an XML list or cells that have been mapped to a particular XML map. This method is particularly useful when building automated XML-based reporting processes where data is programmatically imported from XML documents in shared locations. In the example shown here, the code imports data from the EmployeeSales.xml file to the specified XML map:

Sub ImportXmlFromFile()

ThisWorkbook.XmlMaps("EmployeeSales_Map").Import _ (ThisWorkbook.Path & "\EmployeeSales.xml")

End Sub

XML Events

The Workbook object provides a few XML events that allow you to define and manage what happens before and after import and export procedures:

□ BeforeXMLImport: This event is typically used to trap XML data before it is imported, allowing for data and environment evaluations.

□ AfterXMLImport: This event is typically used to perform some post-processing operations after XML data has been imported.

□ BeforeXMLExport: This event is typically used to trap XML data before it is exported, allowing for data and environment evaluations.

□ AfterXMLExport: This event is typically used to perform some post-processing operations after XML data has been exported.

These events are also exposed through the Application object in the following forms:WorkbookBeforeXMLImport, WorkbookBeforeXMLExport, WorkbookAfterXMLImport, and WorkbookAfterXMLExport.

+1 0

Post a comment