I am writing a code using Application.ExportXML that will export various Access queries to a single XML file. I have the code so far and it is working, but I want to label each record within the query's data that will be exported. For example, I have one query listed in the XML file called "portOfCallList" but I want each record to be labeled "portOfCall". Right now one record looks like this:
- <portOfCallList>
<arrivalDate>2015-07-17T00:00:00</arrivalDate>
<departureDate>2015-07-17T00:00:00</departureDate>
<portOfCallName>Southampton</portOfCallName>
<portOfCallCode>GBSOU</portOfCallCode>
</portOfCallList>
I want it to look like this:
- <portOfCallList>
- <portOfCall>
<arrivalDate>2015-07-17T00:00:00</arrivalDate>
<departureDate>2015-07-17T00:00:00</departureDate>
<portOfCallName>Southampton</portOfCallName>
<portOfCallCode>GBSOU</portOfCallCode>
</portOfCall>
'And then have various other records also labeled "portOfCall" before ending with
</portOfCallList>.
This is the only thing I need to add into my code, since the rest of the code does what I need it to do. I can post the code if need be.
Let me know if I can explain anything further, and thanks!
Kirby
To style your xml file you will need to use an XSLT stylesheet. XSL is a special-purpose declarative language used to transform xml documents.
Hence, given your output from MS Access, you can then use MS Access VBA to transform the raw output xml to your required modified xml format:
First, save the following as an .xsl file:
Second, run the VBA:
Output would look as intended (I repeated your posted data as example):