将多个访问表导出到单个XML

时间:2021-01-24 15:38:56

I have multiple Microsoft Access tables that I want exported into a single XML file. How do I manipulate the order and hierarchy of the tables into the XML structure that I want? In essence, I want to be able to reverse the import XML process, which automatically breaks down the data into multiple tables. I can use VBA, SQL, and any built-in export function at my disposal.

我有多个Microsoft Access表,我希望将它们导出到一个XML文件中。如何将表的顺序和层次结构转换为我想要的XML结构?本质上,我希望能够逆转导入XML过程,该过程自动将数据分解为多个表。我可以使用VBA、SQL和任何内置的导出函数。

2 个解决方案

#1


5  

I use the attached to produce a 3 million line nested xml in about five minutes.

我使用附件在大约5分钟内生成一个300万行嵌套的xml。

There are two key items,

有两个关键项目,

1) a simple piece of VB,

1)一个简单的VB,

Public Function Export_ListingData()

    Dim objOtherTbls As AdditionalData

    On Error GoTo ErrorHandle
    Set objOtherTbls = Application.CreateAdditionalData
    objOtherTbls.Add "ro_address"
    objOtherTbls.Add "ro_buildingDetails"
    objOtherTbls.Add "ro_businessDetails"
    objOtherTbls.Add "ro_businessExtras"
    objOtherTbls.Add "ro_businessExtrasAccounts"
    objOtherTbls.Add "ro_businessExtrasAccom"
    objOtherTbls.Add "ro_businessExtrasAccom2"

    Application.ExportXML ObjectType:=acExportTable, _
                DataSource:="ro_business", _
                DataTarget:="C:\Users\Steve\Documents\Conversions\ListData.xml", _
                AdditionalData:=objOtherTbls
Exit_Here:
        MsgBox "Export_ListingData completed"
        Exit Function
ErrorHandle:
        MsgBox Err.Number & ": " & Err.Description
        Resume Exit_Here
End Function

2) Linking the tables in relationship manager using joins from primary to FOREIGN keys.

2)使用从主键到外键的连接来连接关系管理器中的表。

If there are no relationships the code will produce a sequential xml file, if there are relationships between primary keys you will get a 31532 error and the data export will fail.

如果没有关系,代码将生成一个连续的xml文件,如果主键之间存在关系,您将得到一个31532错误,数据导出将失败。

#2


3  

here is the solution via VBA:
http://msdn.microsoft.com/en-us/library/ff193212.aspx

以下是通过VBA实现的解决方案:http://msdn.microsoft.com/en-us/library/ff193212.aspx

create a from and put a button on it. right click on the button and choose "build event" and past the following code:

创建一个from,并在上面放一个按钮。右键点击按钮,选择“build event”,通过以下代码:

Dim objOtherTbls As AdditionalData


Set objOtherTbls = Application.CreateAdditionalData

'Identify the tables or querys to export
objOtherTbls.Add "internet"
objOtherTbls.Add "mokaleme"

'Here is where the export takes place
Application.ExportXML ObjectType:=acExportTable, _
DataSource:="internet", _
DataTarget:="C:\myxml.xml", _
AdditionalData:=objOtherTbls

MsgBox "Export operation completed successfully."

you have to type the name of your tables here and between quotations:

您必须在这里输入您的表名,并在报价之间输入:

   objOtherTbls.Add "internet"
    objOtherTbls.Add "mokaleme"

    DataSource:="internet"

#1


5  

I use the attached to produce a 3 million line nested xml in about five minutes.

我使用附件在大约5分钟内生成一个300万行嵌套的xml。

There are two key items,

有两个关键项目,

1) a simple piece of VB,

1)一个简单的VB,

Public Function Export_ListingData()

    Dim objOtherTbls As AdditionalData

    On Error GoTo ErrorHandle
    Set objOtherTbls = Application.CreateAdditionalData
    objOtherTbls.Add "ro_address"
    objOtherTbls.Add "ro_buildingDetails"
    objOtherTbls.Add "ro_businessDetails"
    objOtherTbls.Add "ro_businessExtras"
    objOtherTbls.Add "ro_businessExtrasAccounts"
    objOtherTbls.Add "ro_businessExtrasAccom"
    objOtherTbls.Add "ro_businessExtrasAccom2"

    Application.ExportXML ObjectType:=acExportTable, _
                DataSource:="ro_business", _
                DataTarget:="C:\Users\Steve\Documents\Conversions\ListData.xml", _
                AdditionalData:=objOtherTbls
Exit_Here:
        MsgBox "Export_ListingData completed"
        Exit Function
ErrorHandle:
        MsgBox Err.Number & ": " & Err.Description
        Resume Exit_Here
End Function

2) Linking the tables in relationship manager using joins from primary to FOREIGN keys.

2)使用从主键到外键的连接来连接关系管理器中的表。

If there are no relationships the code will produce a sequential xml file, if there are relationships between primary keys you will get a 31532 error and the data export will fail.

如果没有关系,代码将生成一个连续的xml文件,如果主键之间存在关系,您将得到一个31532错误,数据导出将失败。

#2


3  

here is the solution via VBA:
http://msdn.microsoft.com/en-us/library/ff193212.aspx

以下是通过VBA实现的解决方案:http://msdn.microsoft.com/en-us/library/ff193212.aspx

create a from and put a button on it. right click on the button and choose "build event" and past the following code:

创建一个from,并在上面放一个按钮。右键点击按钮,选择“build event”,通过以下代码:

Dim objOtherTbls As AdditionalData


Set objOtherTbls = Application.CreateAdditionalData

'Identify the tables or querys to export
objOtherTbls.Add "internet"
objOtherTbls.Add "mokaleme"

'Here is where the export takes place
Application.ExportXML ObjectType:=acExportTable, _
DataSource:="internet", _
DataTarget:="C:\myxml.xml", _
AdditionalData:=objOtherTbls

MsgBox "Export operation completed successfully."

you have to type the name of your tables here and between quotations:

您必须在这里输入您的表名,并在报价之间输入:

   objOtherTbls.Add "internet"
    objOtherTbls.Add "mokaleme"

    DataSource:="internet"