I receive 2 XML files from a third party service every day and I need to combine them using VBS as it is the only available technology on the server that consumes the XML. Each of the XML files has the same structure –
<section>
<lot>
<number>8</number>
<identifier>au23-zx78a</identifier>
</lot>
<lot>
<number>23</number>
<identifier>au23-zx78a</identifier>
</lot>
...and so on...
</section>
I need to take all of the lot nodes (including any and all children) from file 1 and insert them into file 2 before saving file 2 to be consumed by another service. Using VBS.
I have searched the web and I have found ways to get a node out using VBS but I am lost on getting the nodes into another file. I have written and scrapped 3 or 4 scripts today because I have not been able to get it right.
I know that the logic is this –
load file 1,
load file 2,
get the lot nodes from file 1,
loop through the lot nodes from file 1 and append them as children of the section node in file 2,
save file 2
Can anyone help me by pointing me in the right direction?
Here’s a simple way of doing it: load both xml files into
MSXML2.DomDocumentobjects, select all thelotnodes from the first document, clone them and insert them into the second document.The script (if called merge-xml.vbs) would be run from the command line