[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Copy DOM_Node from one DOM_Document to another DOM_Document?
- From: Eric Rehm <rehm@singingfish.com>
- To: xml-dev@lists.xml.org
- Date: Tue, 19 Jun 2001 14:52:47 -0700
I'm using Apache Xerces-C V1.4.0.
I've got two DOM_Documents in memory, and I want to subtitute a DOM_Node
instance
in one DOM_Document for another.
Doc1:
-----
<Mpeg7>
<AudioVisual>
<CreationInformation>...oldChildern..</CreationInformation> // oldChild
</AudioVisual>
</Mpeg7>
Doc2:
-----
<Foo>
<CreationInformation>...newChildren...</CreationInformation> // newChild
</Foo>
Modified Doc1:
--------------
<Mpeg7>
<AudioVisual>
<CreationInformation>...newChildren...</CreationInformation> // oldChild
</AudioVisual>
</Mpeg7>
However, I can't do this directly, i.e., the following code generates
DOMException::WRONG_DOCUMENT_ERR:
// Find parent in doc1
DOM_Element audioVisualElem =
mp7->findElementByName("AudioVisual", 0);
// Find oldChild in doc1
DOM_Element oldCreationInformationElem =
mp7->findElementByName("CreationInformation", 0);
// Find newChild in doc2
DOM_Element newCreationInformationElem =
mp7LabelObj->findElementByName("CreationInformation", 0);
// So far so good...
// Replace doc1/oldchild with doc2/newchild
// EXCEPTION: WRONG_DOCUMENT_ERR
audioVisualElem.replaceChild(newCreationInformationElem,
oldCreationInformationElem);
This exception makes a lot of sense, i.e., that DOM_Node's belong
to their DOM_Document parent. However, is there any way to do this?
/eric rehm
singingfish.com
a thomson multimedia company
rehm@singingfish.com
1.206.883.3013
1.206.354.3459 (cell)