If your XML is that simple and nicely structured, you can write regular 
expressions (or use similar text operations) to extract the <product> sections 
and put them back to back and slap a <rootelement> </rootelement> to the 
beginning and the end. If you keep the result in the memory, it's still going 
to be a large String, so you might want to write the XML to a file as you 
process your input.

I don't know that's the best approach but with a simple XML, it seems pretty 
easy to implement.

Muzaffer

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:dom4j-user-
> [EMAIL PROTECTED] On Behalf Of Håkan Jacobsson
> Sent: Tuesday, January 15, 2008 7:39 AM
> To: [email protected]
> Subject: [dom4j-user] Merging several XML-files
>
> Hi,
>
> What would be the best approach to merging several XML files?
> The files are big, so I can't keep them in memory.
> Example:
>
> xml document 1:
>
> <rootelement>
>    <product>
>        <data>somedata</data>
>    </product>
> </rootelement>
>
>
>
> xml document 2:
>
> <rootelement>
>    <product>
>        <data>someotherdata</data>
>    </product>
> </rootelement>
>
>
>
> result.xml:
>
> <rootelement>
>   <product>
>        <data>somedata</data>
>    </product>
>  <product>
>        <data>someotherdata</data>
>    </product>
> </rootelement>
>
>
> That is, I just want to append all elements below the root
> element from file2, 3 etc. into file1 (just before the
> </rootelement> tag).
> When all data from file2,3 etc.is appended I would append the
> </rootelement> tag.
>
> /Best regards, Håkan Jacobsson - System developer in Sweden
>
>
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> dom4j-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
dom4j-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to