dusker
dusker

Reputation: 580

Joining several XML documents using Java

i have several xmls that are of the same format, and i'd like to join them together into one big xml file. Is there any useful class that would let me grab specific nodes and mix them together, or do i have to parse all of the xmls through and create a new one? regards peter

Upvotes: 3

Views: 215

Answers (3)

Tushar Tarkas
Tushar Tarkas

Reputation: 1622

You can also use XSLT for doing this. Check this for more details. You can use XSLTransformer API in java.

Upvotes: 0

Tassos Bassoukos
Tassos Bassoukos

Reputation: 16152

This entirely depends on whet the structures of the XML files represent. You cannot just concatenate them, as then you will have multiple root elements. While you can use SAX parsers to copy contents without loading the whole files in memory, you still need to figure out how to interleave the contents.

Upvotes: 1

bua
bua

Reputation: 4890

If the format is simple and the joins would not be nested deeply,
Why not throw header away, and join the text?

If the join would be more complex apache commons would come with a helping hand.
So parsing would be most reasonable solution though.

Upvotes: 1

Related Questions