in reply to Multiple XML files from Directory to One XML file using perl.
You are indeed picking an ambitious project for your first experience with the Perl language, but let me give you a website that you must bookmark: http://search.cpan.org.
If you go to that site and type, “XML,” then ... oops! ... you get 5,000 hits. So, here are a couple of searches to have a look at:
Your general approach will be to construct a new XML object representing your output file, and then to cycle through a directory (search e.g. for File::Find), open each one of the XML files you find there, and transfer nodes and subtrees from one to the other.
You may (erroneously, as it turns out) assume that you must write complicated code to navigate through the structure to see if things already exist, but you don’t: that is what “XPath expressions” are for. True XML difference-engines are also available.
Your strategy will partly depend on how large these files actually are.
You might also discover that there are altogether different ways to do it, such as XSLT, and existing engines such as Saxon. In the desktop publishing world, DocBook is used to write documentation and books in an XML-based format, and books are actually assembled from hundreds or thousands of component parts using (a little hand-waving here ... what I am saying is not quite true...) no programming at all. Because XML is now used so widely and in so many ways, the company of available tools is quite large and mature ... and, “Perl is there.”
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multiple XML files from Directory to One XML file using perl.
by jyo (Initiate) on Nov 18, 2011 at 15:30 UTC | |
by marto (Cardinal) on Nov 18, 2011 at 15:37 UTC | |
by jyo (Initiate) on Nov 18, 2011 at 17:40 UTC | |
by Anonymous Monk on Nov 18, 2011 at 15:37 UTC |