Sorry about that. I started with a very basic example with only one
document, then thought I should indicate I was importing the
DocumentFragment,
thus introducing typos. Here is the code (tested this time).
All I wanted to do was to import an arbitrary number of Nodes and insert
them into a known Node in my target document, but still keep track of what
where the Node that I had inserted, in order to be able to easily replace
them with an arbitray number of Nodes. Now that I know what is a
DocumentFragment, I will use a List of Nodes instead, and do the replace
operation Node per Node.
javax.xml.parsers.DocumentBuilderFactory dbf=
javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder db= dbf.newDocumentBuilder();
org.w3c.dom.Document doc1= db.newDocument();
org.w3c.dom.Document doc2= db.newDocument();
org.w3c.dom.Node a= doc1.createElement("a");
org.w3c.dom.Node c= doc1.createElement("c");
org.w3c.dom.Node c1= doc1.createElement("c1");
c.appendChild(c1);
a.appendChild(c);
org.w3c.dom.Node b1= doc2.createElement("b1");
org.w3c.dom.Node b3= doc2.createElement("b3");
org.w3c.dom.DocumentFragment docFrag2= doc2.createDocumentFragment();
docFrag2.appendChild(b1);
docFrag2.appendChild(b3);
org.w3c.dom.Node docFrag1= doc1.importNode(docFrag2, true);
c.replaceChild(docFrag1, c1);
Cheerio!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]