Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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?

Comment on merging XML file
Download Code
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 (Deacon) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://755442]
Approved by linuxer
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2015-07-29 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls