Re: [xml] Pasting fragment
- From: chrisbee xml swing be
- To: xml gnome org
- Subject: Re: [xml] Pasting fragment
- Date: Thu, 22 Aug 2002 15:50:37 +0200
> On Thu, Aug 22, 2002 at 01:41:52PM +0200,
chrisbee xml swing be wrote:
> > 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)
> > {
> > .....
> > }
> > }
>
> looks okay a priori. But I really can't understand why you don't
> want to pass node->doc to xmlParseBalancedChunkMemory() , to later
> update it everywhere in the resulting nodes ... This makes absolutely no
> sense to me !
Because I do some tests before and calling xmlParseBalancedChunkMemory()
initialized doc->children with the result node llist. But it seems that
this happens only if doc->children is NULL (Is this a bug ?). At this
time, I (wrongly) concluded that when a doc argument was provided,
xmlParseBalancedChunkMemory() replaces doc->children with the result
nodes of parsing.
OK! now I do the following instead
xmlNodePtr nodeList;
if (xmlParseBalancedChunkMemory(node->doc, NULL, NULL, 0, (xmlChar *)str, &nodeList) == 0)
{
if (xmlAddChildList(node, nodeList) == NULL)
{
...
}
}
Thank you for your help.
Christophe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]