My requirement is to export a row from Excel to XML. For example, if spreadsheet looks like this:
MessageID OriginalField OriginalCOBO RevisedCOBOL ChangeIndicator
I23456I SDQ SOURCE SOURCE-DATA-QUEUE 1
Then, I need to create a xml based on [Change Indicator]=1
.
Column values need to be element tag, not the column header. For example, desired output would be:
<I23456I>
<SDQ>
<COBOLName>SOURCE-DATA-QUEUE</COBOLName>
</SDQ>
</I23456I>
MessageID
and OriginalField
values will be keep changing and it is not the same for all.
Appreciate any help.
Consider using the MSXML VBA object to create your XML nodes and tags iteratively, conditional on the fifth column:
[Change Indicator] = 1
. At the end a pretty print XSLT stylesheet is used to properly line break and indent outputted XML. Do note: aRoot
tag is added for a well-formed XML file:Output