0

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

2

2 Answers 2

3
String merged = "<root>" + str1 + str2 + "</root>";
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.