I have two tables CR and RELEASE with relationship from CR (ID) to RELEASE (CRID) one to many.
CR (design):
ID: key, unique
Description: text
RELEASE (design):
ID: key, unique
CRID: number, not unique
Name: text
With the following VBA code, I am managed to export the tables to XML.
Set objOrderInfo = Application.CreateAdditionalData
objOrderInfo.Add ("RELEASE")
Application.ExportXML ObjectType:=acExportTable, DataSource:="CR", _
DataTarget:=pFileNAme, _
AdditionalData:=objOrderInfo
The exported XML is something like:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2015-12-09T09:34:28">
<CR>
**<ID>1</ID>**
<Description>Test</Description>
<RELEASE>
<ID>1</ID>
**<CRID>1</CRID>**
<Name>R2016</Name>
</RELEASE>
<RELEASE>
<ID>2</ID>
**<CRID>1</CRID>**
<Name>R2017</Name>
</RELEASE>
</CR>
Note that CRID showed several times in the XML which is practically redundant. How to remove the CRID elements from RELEASE element in XML? Thanks,
I can't see how you could. After all, CRID is a field of table RELEASE:
If you need to tweak the XML output after using
Application.ExportXML
you could do the initial export to a temporary XML file and then use an .xslt file like this:and a VBA routine like this
to remove
<CRID>
from the<RELEASE>
element.