Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

merging XML file

by Anonymous Monk
on Apr 04, 2009 at 14:08 UTC ( #755442=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dears I would like to merge few xml file in a simple way.
xml file 1 <head> <t> 1 </t> <t> 15 </t> <t> 17 </t> </head> xml file 2 <head> <t> 26 </t> <t> 19 </t> <t> 0 </t> </head> merged file: <head> <t> 1 </t> <t> 15 </t> <t> 17 </t> <t> 26 </t> <t> 19 </t> <t> 0 </t> </head>
which method is the fastest and easier? which xml module would be suggested?

Replies are listed 'Best First'.
Re: merging XML file
by moritz (Cardinal) on Apr 04, 2009 at 14:23 UTC
    Please see Concatenating XML files, I found the answers quite helpful.

    It won't get you there to 100%, but it'll show you how similar things are done with various XML modules.

Re: merging XML file
by linuxer (Curate) on Apr 04, 2009 at 16:07 UTC

    My CPAN search for xml merge revealed a module XML::Merge. Maybe that can be helpful in your case?

Re: merging XML file
by Bloodnok (Vicar) on Apr 04, 2009 at 15:50 UTC
    moritzs suggestion apart (I haven't yet been to have a look), it looks (from slightly sparse evidence) like you want a simple merge of 2 (or maybe more) XML files, so why not ...
    1. Read each file into its own hash (using XMLin() from XML::Simple,
    2. Merge all the input hashes
    3. Finally, write the resultant hash using XMLout() (again from XML::Simple).
    Assuming, of course, that the combined size of the input XML files isn't huge (and thus likely to cause the process to run out of memory).

    A user level that continues to overstate my experience :-))

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://755442]
Approved by linuxer
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-06-21 03:10 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.