So obviously you can't do that. Let's look at the requirements more carefully then. (I didn't really see any requirements in your post, though, so I'm going with the title of the
thread as your requirements.)
First of all, as you probably know an XML document can only have a single root element. So the result of merging two XML documents, each of which has a single root element, can itself have only a single root element. So what is it going to be? The root of the first document? The root of the second document? Something different?
Okay, let's suppose you have that requirement taken care of. Let's suppose you're generating a new root element for the result document. Then what is supposed to happen to the root elements of the two input documents. Do they get discarded? Or are they used as the only two children of the result document's root?
Okay. Let's suppose you have that requirement taken care of. Let's suppose that the root elements of the two input documents get discarded. Then presumably you want to take all of the child nodes of those two roots and make them be child nodes of the result document's root. What order do you want them to be in? First document's nodes then second document's nodes? Or something else? And do you want anything special done with whitespace text nodes?
Now I might have chosen the wrong questions to ask, because the questions I asked depended on the answers I guessed for earlier questions. But the point is that it's up to you to ask those questions. Right now you don't know what your requirements are, so you don't know what to do. In which case there is no point in writing code. Get the requirements written down first.