I need to merge two XML files in Excel VBA. 2nd XML file should be added as a sibling of 1st XML. Also have to create a Union after merging the XML files. For example:
1st XML file:
<TupleList>
<Member FullPath="Latest : FOLDER Day Ending 06-16-2019"/>
</TupleList>
2nd XML file:
<TupleList>
<Member FullPath="Latest : FOLDER Day Ending 06-17-2019"/>
</TupleList>
Expected Output XML file:
<Union>
<TupleList>
<Member FullPath="Latest : FOLDER Day Ending 06-16-2019"/>
</TupleList>
<TupleList>
<Member FullPath="Latest : FOLDER Day Ending 06-17-2019"/>
</TupleList>
</Union>
I tried below code but its not working as expected
Set XOuter = CreateObject("MSXML2.DOMDocument")
Set XOuter1 = CreateObject("MSXML2.DOMDocument")
Dim appendNode As MSXML2.IXMLDOMNode
XOuter.Load ("C:\\blp\\1stXML.xml")
XOuter1.Load ("C:\\blp\\2ndXML.xml")
For Each appendNode In XOuter1.DocumentElement.ChildNodes
XOuter.DocumentElement.appendChild appendNode
Next
It provides output with Tuplelist as parent and 2 Members as Child. But I want output in above-expected format.
Unionbefore the tuplelist. Updated the expected output