简体   繁体   中英

MS Access to create XML

I have a sample file from a customer and need to match the schema with data from various tables in my MS Database.

Tried writing a query and exporting the XML but it oversimplifies the XML and assumes that each row from the query is a single node and all the data elements fall under each instance of that node.

Is there a way to setup a schema (possibly build it by importing my sample file) and then map fields to that for the export?

I'm open to using Excel if by chance it is better suited - just figured the access relationships would be better.

Perhaps you are looking for something like:

Sub ExportCustomerOrderData()

    Dim objOrderInfo As AdditionalData

    Dim objOrderDetailsInfo As AdditionalData



    Set objOrderInfo = Application.CreateAdditionalData



    '' Add the Orders and Order Details tables to the data to be exported.

    Set objOrderDetailsInfo = objOrderInfo.Add("Orders")

    objOrderDetailsInfo.Add "Order Details"



    '' Export the contents of the Customers table. The Orders and Order

    '' Details tables will be included in the XML file.

    Application.ExportXML ObjectType:=acExportTable, DataSource:="Customers", _

                          DataTarget:="Customer Orders.xml", _

                          AdditionalData:=objOrderInfo

End Sub

From: http://msdn.microsoft.com/en-us/library/ff193212.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM