Description
I am trying to import node from one document and adding that node to the other document...
corrupt_impl = DOMImplementationRegistry::getDOMImplementation(XML);
if (corrupt_impl != NULL)
Loop()
{
DOMNode* corrupted = List; /* getting the node from other document */
corruptedRoot->appendChild(corruptedDoc->importNode(corrupted, true));
}
DOMErrorHandler WriterErrHandler = (DOMErrorHandler) new HandlerBase();
corruptwriter->setErrorHandler(WriterErrHandler);
/* set the features to the writer.*/
if(corruptwriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
corruptwriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint , true);
/* write the entire document to the file */
corruptwriter->writeNode(corruptfile , *corruptedDoc);
corruptedDoc->release();
if I run the code every time when the Loop() repeats new node is added to the root only but in the previous line like this.
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<personnel>
<person id="one.worker">
<name>
<family>Worker</family>
<given>One</given>
</name>
<email>one@foo.com</email>
</person><person id="three.worker">
<name>
<family>Worker</family>
<given>One</given>
</name>
<email>one@foo.com</email>
</person>
</personnel>
But I need the output as following. How can I achieve it..
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<personnel>
<person id="one.worker">
<name>
<family>Worker</family>
<given>One</given>
</name>
<email>one@foo.com</email>
</person>
<person id="three.worker">
<name>
<family>Worker</family>
<given>One</given>
</name>
<email>one@foo.com</email>
</person>
</personnel>