Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
go ahead... be a heretic
 
PerlMonks  

Re: Conatenating XML files

by john_oshea (Priest)
on Jul 30, 2007 at 15:17 UTC ( #629592=note: print w/ replies, xml ) Need Help??


in reply to Concatenating XML files

XML::LibXML::Document has a toString() method that converts the parsed DOM into a string, including all the child nodes. It has an optional format parameter, which, when set to zero "...the document is dumped as it was originally parsed".

Depending on how lazy / strict you're feeling you could either:

  • just serialize each document into a string and use (anchored) regexes to strip off the document root
  • use the documentElement() method to get the root of each document, then loop through its childNodes array, and individually toString() each of those

I'd be surprised if there isn't an XML::Twig equivalent to that - I'm just personally much more familiar XML::LibXML - hope that helps.


Comment on Re: Conatenating XML files
Select or Download Code
Re^2: Conatenating XML files
by moritz (Cardinal) on Jul 30, 2007 at 15:51 UTC
    Thank you john_oshea. Probably there is such a method in XML::Twig, but knowing another module that does the job is fine for me as well.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (16)
As of 2014-04-18 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls