Re: [xml] using xmlDocSetRootElement to move nodes between documents

Igor Zlatkovic wrote:
On 27/07/04 19:11, Martijn Faassen wrote:
is moving nodes between documents in general not supported this way?

No, it isn't. You must call xmlUnlinkNode to get the node out of the first document. Then you can insert it into the new document. And take a good care about namespaces, should either document use them.

Unless I'm missing something, this cannot be it, as xmlDocSetRootElement() calls xmlUnlinkNode on the node in any case:

xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
    xmlNodePtr old = NULL;

    if (doc == NULL) return(NULL);
    if (root == NULL)

I also tried using xmlSetTreeDoc, but that doesn't help either (and it's hard to say what to call it in the original document, as I'm moving the document element).



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]