Jane Jin (janej) schrieb:
> Hi xerces gurus out there,
>
> I have two DOMDocument* object -- say doc1 and doc2. I'd like to make
> doc2 a child of doc1 -- sort of doing:
>
> (doc1->getDocumentElement)->appendChild(doc2)
>
> Of course I can always parse doc2 into individual DOMNodes, traverse
> the doc2 tree and append node one by one to doc1. But is there a quick
> way to do this without parsing doc2?
Hi Jane,
the quickest way I know consists of two steps.
1. Import (and make a deep clone of) the root element of doc2:
DOMNode *node = doc1->importNode(doc2->getDocumentElement(), true);
2. Append the clone:
doc1->getDocumentElement()->appendChild(node));
Happy with this?
Axel
--
Humboldt-Universität zu Berlin
Institut für Informatik
Signalverarbeitung und Mustererkennung
Dipl.-Inf. Axel Weiß
Rudower Chaussee 25
12489 Berlin-Adlershof
+49-30-2093-3050
** www.freesp.de **