Re: [xml] Pasting fragment



Hi Daniel,
I can't figure out how I have to correctly plug resulting node list into an node of an existing document.
Could you, please, tell me if what follows is the correct way to parse a balanced string and plug the result into an existing node ?

// Assume node must become the parent of the parsed balanced string str:
xmlNodePtr nodeList;
// First parameter (doc) set to NULL (Undocumented behaviour).
// -> Avoids the resulting nodes to be attached an existing document.
if (xmlParseBalancedChunkMemory(NULL, NULL, NULL, 0, (xmlChar *)str, &nodeList) == 0)
{  
    // OK it is a balanced chunk
    // Recursively update all doc of nodeList
    // NB: It must be done before xmlAddChildListNode!
    //     Otherwise xmlSetListDoc don't update children doc.
    xmlSetListDoc(nodeList, node->doc);
                                      
    if (xmlAddChildList(node, nodeList) == NULL)
    {
      .....
    }
}



 


On Tue, Aug 20, 2002 at 05:51:33PM +0200, chrisbee xml swing be wrote:
> Hi,
>
> I read the thread "Pasting fragment" (date 12/04/2002) and I'd like to get precisions about xmlParseBalancedChunkMemory. If the argument doc is not NULL, does children of doc initialized with the resulting list of nodes ? If yes, how can I parse a balanced chunk and get the list of nodes without making it children of a doc ?

Hum, apparently, no. But I don't see why this would be a hard problem,
just create a temporary doc. On the other hand every node in a tree has
a doc pointer associated to the the containing document, this is used a lot
and trying to bypass this can cause problems.

Daniel

--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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