You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Sébastien Chevriau <se...@yahoo.fr> on 2003/05/21 13:25:41 UTC

How to convert DOMNode into DOMDocument ?? (self-solution)

One solution I've found is :

// get node ref into node

// create DOMDocument with DocumentElement that has name of node
doc2 = impl->createDocument(0, node->getNodeName(), 0);
// get DocumentElement ref
node = doc2->getDocumentElement();
// get all childs of node
domNodeList = node->getChildNodes();
// for each, append it to DocumentElement
for (i=0; i<domNodeList->getLength(); i++)
{
    node->appendChild(doc2->importNode(domNodeList->item(i), TRUE));
}

It works with this method but it sounds like "not clean"

What do you think about it ?

Sebastien Chevriau

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org