Altova XMLSpy 2024 Enterprise Edition

To export data to a database, carry out the steps below:

 

1.Use a DatabaseConnection object and set the necessary properties. All properties except SQLSelect are important for the export. ADOConnection or File defines the target for the output. You need to set only one of them.

2.Fill an ExportSettings object with the required values. These properties are the same options as those available in the export dialog of XMLSpy. Select the menu option Convert | Export to Text files/Database to see the options and try a combination of export settings. After that it is easy to transfer these settings to the properties of the interface. Call Application.GetExportSettings to get an ExportSettings object: objExpSettings = objSpy.GetExportSettings()

3.Build an element list with Document.GetExportElementList. The element list enables you to eliminate XML elements from the export process. It also gives you information about the record and field count in the RecordCount and FieldCount properties. Set the ExportSettings.ElementList property to this collection. It is possible to set the element list to null/Nothing (default) to export all elements.

4.Call Document.ExportToDatabase to execute the export. The description of the ExportToDatabase method contains also a code example for a database export.

 

 

  // set the behaviour of the export with ExportSettings
  objExpSettings = objSpy.GetExportSettings()
 
  //set the destination with DatabaseConnection
  objDB = objSpy.GetDatabaseSettings();
  objDB.CreateMissingTables = true;
  objDB.CreateNew = true;
  objDB.File = "C:\\Temp\\Export.mdb";
 
try
{
  objImpDocFromDB.ExportToDatabase(objImpDocFromDB.RootElement, objExpSettings, objDB);
}
catch(err)
{
  WScript.Echo("Error exporting to database.\" +
                    "Error: " + (err.number & 0xffff) + "\" +
                    "Description: " + err.description);
}

 

 

The JScript code listed above is available in the sample file ImportExport.js (see Example Files).

© 2017-2023 Altova GmbH