I need to embed arbitrary (syntactically valid) XML documents within a wrapper XML document. The embedded documents are to be regarded as mere text, they do not need to be p
You need to properly escape the text. You don't say what language you're using, but generally: you build a DOM, create a Text node that contains your "inner" XML, and then serialize that DOM. The serializer will handle escaping for you.
The key point here is use a serializer to produce your output. Don't simply write strings, because you're all but guaranteed to produce something that's not well-formed XML.