The exception that you are getting is because you are trying to append a
node that belongs to another document.

To import a node from one document to another (whether it is a node, and
element, or whatever) you must first use the DOM Document method
'importNode'

DOM_Document doc1( getMyMagicalDocument1() );
DOM_Document doc2( getMyMagicalDocument2() );

// Let's get the 2nd document's root element...
DOM_Element rootElem = doc2.getDocumentElement();

// Import the that root element into the 1st document...
DOM_Element importedElem = (const DOM_Element&)doc1.importNode( rootElem );

// And finally append the imported element to the 1st document's root
element
doc1.getDocumentElement().appendChild( importedElem );

This works the same in either the C++ or Java versions of Xerces, though the
syntax is slightly different.  (For Java remove the 'DOM_' prefix and change
the casting to Java's)





-----Original Message-----
From: Joakim [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 22, 2000 12:38 PM
To: '[EMAIL PROTECTED]'
Subject: question.


Will xerces provide method for appending other Node implementation
beside NodeImpl?

Now when i try to appendChild of another Node implementation the 
following error is raised "WRONG_DOCUMENT_ERR".
Why not make a conversion to xerces Node type instead of casting that 
exception?

//jocke

Joakim Olausson ([EMAIL PROTECTED])
CIC ([EMAIL PROTECTED])
Internet   http://www.cic.se
Telephone. +46 521 26 20 00
Telefax.   +46 521 26 20 20

Reply via email to