OL Learn

Rebuild multiple XML files into a single XML


How would you go about merging a folder full of XML files into a single XML ready for processing through a datamapper?



You could use XSLT. See this post

Thanks @hamelj how would I apply that in workflow?

You would need to use the XSLT plugin of Workflow. More than that, sorry…I have to say I do not understand XSLT.

Reach out for XSLT assistance.

Hi @jim3108, that would be great thanks - I have a folder full of XML files which I am pre-processing with additional data, these are then being written out to a temp folder of XML files again. At which point I want to grab that folder using the folder capture plugin and then use the XSLT plugin to merge them into a single XML file.

Would something like this be possible?

Just thinking but have you thought about just trimming off the root nodes and outputting to a single file using Send to Folder with concatenate files switched on?

Hi @jim3108,

I had but wasn’t sure how I can remove the root nodes using workflow - would it be best to run a script over each XML file being read? Similar to the javascript I’m using to add the extra nodes into the dataset?


Just use the Add/Remove Text plugin three times. Once to remove 2 lines from the top - the XML header and the top tag. Second time to add the XML header back in. Third time to remove the bottom tag.

Make sense?

Yup, thanks @jim3108.

First loop through the folder - removing the XML headers, top tags and bottom tags for each record, concatenating the result. Effectively leaving just the node data. Then finally add the XML header, top tag and bottom tag back in to the ‘combined’ results…