Embed xml doc within an xml doc from untruted source?

Off topic but I am sure someone here might have seen this: I have a web service which returns an xml document. Within this document I embed an xml document from a foreign source (so I dont want the validity of my xml to be predicated on whatever this provider happens to return. This foreign xml doc by the way contains a CDATA within it, so wrapping the full xml doc in CDATA does not work. The best I can come up with is to escape the entire foreign xml with <lt; and <gt;. Is there another better way to go about this?

David

David Kahn wrote in post #967475:

Off topic

Then don't post it here!

but I am sure someone here might have seen this: I have a web service which returns an xml document. Within this document I embed an xml document from a foreign source (so I dont want the validity of my xml to be predicated on whatever this provider happens to return. This foreign xml doc by the way contains a CDATA within it, so wrapping the full xml doc in CDATA does not work. The best I can come up with is to escape the entire foreign xml with <lt; and <gt;. Is there another better way to go about this?

I've seen the suggestion to just escape the ]]> in the inner CDATA to ]]&gt;

But this seems like a dreadful way to go about the problem. If you can reanalyze your design so you don't need the nested XML documents, do; otherwise, take this discussion to an XML community where it will be on topic and where more XML gurus will be able to answer your question.

David

Best,