moritz has asked for the wisdom of the Perl Monks concerning the following question:
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conatenating XML files
by un-chomp (Scribe) on Jul 30, 2007 at 15:08 UTC | |
by moritz (Cardinal) on Jul 30, 2007 at 15:51 UTC | |
|
Re: Conatenating XML files
by mirod (Canon) on Jul 30, 2007 at 16:07 UTC | |
by graff (Chancellor) on Jul 30, 2007 at 17:39 UTC | |
by mirod (Canon) on Jul 30, 2007 at 18:10 UTC | |
by moritz (Cardinal) on Jul 30, 2007 at 18:28 UTC | |
by mirod (Canon) on Jul 30, 2007 at 18:37 UTC | |
|
Re: Conatenating XML files
by john_oshea (Priest) on Jul 30, 2007 at 15:17 UTC | |
by moritz (Cardinal) on Jul 30, 2007 at 15:51 UTC |