Merge multiple XML files into one using PowerShell 2.0?

Question:

I have a directory of very large XML files with a structure as this:

file1.xml:

file2.xml:

Now I am looking for a simple way to merge these files (*.xml) files into one output file:

I was thinking about using pure XSLT such as this one:

This works but isn’t as flexible as I want. Being a novice with PowerShell (version 2) eager to learn new best pracctices of working with XML in PowerShell I am wondering what is the simplest, purest PowerShell way of merging the structre of XML documents into one?

Cheers,
Joakim

Answer:

While the XSLT way to do this is pretty short, so is the PowerShell way:

Hope this helps,

Source:

Merge multiple XML files into one using PowerShell 2.0? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply