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
from one DOM_Document for a DOM_Node instance in another DOM_Document

        Doc1:
        -----
        <Mpeg7>
          <AudioVisual>
                <CreationInformation>...oldChildern..</CreationInformation>  // 
oldChild
          </AudioVisual>
        </Mpeg7>

        Doc2:
        -----
        <Foo>
                <CreationInformation>...newChildren...</CreationInformation> // 
newChild
        </Foo>

        Modified Doc1:
        --------------
        <Mpeg7>
          <AudioVisual>
                <CreationInformation>...newChildren...</CreationInformation>  // 
newChild
          </AudioVisual>
        </Mpeg7>

However, I can't do this directly, i.e., the following code generates
an access violation (and I can't seem to catch the exception when
I put the replaceChild call in a try...catch block):

        // 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
        audioVisualElem.replaceChild(newCreationInformationElem,
                                             oldCreationInformationElem);

I assume I probably should be seeing a DOMExpection::WRONG_DOCUMENT_ERR.
If so, this exception would make a lot of sense, i.e., each DOM_Node belongs
to it's respective DOM_Document parent, and ;-( you can't change parents.

However, is there another way to do this?  This seems like a common thing
to do: grab a node from one document and append/insert/replace in another
document.

/eric rehm
singingfish.com
a thomson multimedia company
[EMAIL PROTECTED]
1.206.883.3013
1.206.354.3459 (cell)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to