So the files might look like this:
<!-- file 1 --> <?xml version="1.0" encoding="UTF-8"?> <foo> <bar1>some data</bar1> <!-- more data here --> </foo> <!--file 2--> <?xml version="1.0" encoding="UTF-8"?> <foo> <bar2>some more data</bar2> <!-- more data here --> </foo> <!-- this is how the resulting file should look like: --> <?xml version="1.0" encoding="UTF-8"?> <foo> <bar1>some data</bar1> <!-- more data here --> <bar2>some more data</bar2> <!-- more data here --> </foo>
My first attempt was to use XML::Twig, but the vast number of methods overwhelmed me, and I couldn't find one that simply returns a text representation of all the sub elements (including markup).
Is there an easy way to do it with XML::Twig or another XML module?
I could certainly use regexes to parse the beginning of the file and then paste it verbatim until the second-to-last line in the file, but that seems a bit ugly, so I'd appreciate better suggestions ;-)
Update: fixed type in title (how embarrassing)
In reply to Concatenating XML files by moritz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |