You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Brian Dupras <br...@centera.com> on 2000/01/25 19:16:16 UTC
Merge multiple XML Docs into one XML Doc
OK - this should be an easy one, but so far I've yet to find a definitive
answer.
I have a system where I'm given multiple XML DOM Documents that I need to
process and merge into a single DOM Document. The known portions of the
input Documents get processed, while the unknown portions need to be copied
over directly.
The question is, how do I properly insert entire nodes (and their childeren)
from one document to another? Do I have to write my own recursive copy
routine?
I'm free to use either the DOM functions, or XSLT.
Brian
Given as DOM Documents:
<doc1>
<foo>
<replaceme id="a"/>
</foo>
<bar/>
</doc1>
<doc2>
<bar>
<replaceme id="b">
<inserthere thexml="doc1">
</bar>
<foo/>
</doc2>
<doc3>
<inserthere thexml="doc1">
</doc3>
Created from scratch:
<output>
<bar>
<replaced>doc2 id b</replaced>
<foo>
<replaced>doc1 id a</replaced>
</foo>
<bar/>
</bar>
</output>
Brian Dupras
Centera Information Systems, Inc.
phone 303.939.0200 x294
fax 303.939.0111
web http://www.centera.com
email briand@centera.com