tags:

views:

33

answers:

2

What is the best way for me to merge two xml strings in java?

+2  A: 
String merged = "<root>" + str1 + str2 + "</root>";
erickson
+1  A: 

Depends on what you mean by "merge" - if you just need them to become a single document, erickson's solution will work. If you need to blend them together in order to to combine matching tags, etc., you're going to have to start by parsing them into Documents, then combining the parts you care about into a new Document, then writing THAT out as XML.

Curtis