[xml] Possible bug on content addition then node deletion.




        I have an XML structure like this:

        <tag>
<Something>Dogs usually say bark but I say <Replace>value</Replace></_Something>
        </tag>


        Ok, so I add to the content of <Something> with:

        xmlNodeAddContent(cur_node->parent, "blah");

        (cur_node is pointing to <Replace>)

So when I dump the entire doc I get:

        <tag>
<Something>Dogs usually say bark but I say <Replace>value</Replace>blah</_Something>
        </tag>

Ok, cool, now I do this to nuke <Replace> :

        newNode = cur_node->next;
        xmlUnlinkNode(cur_node);
        xmlFreeNode(cur_node);
        cur_node = newNode;

I get when I dump the entire doc:

        <tag>
                <Something>Dogs usually say bark but I say blah</_Something>
        </tag>

That's fine too. Except that 'blah' is not actually part of <Something> in the tree. If I request the text from the <Something> node I get:

        <tag>
                <Something>Dogs usually say bark but I say </_Something>
        </tag>

.... and 'blah' is all on its lonesome elsewhere.  Wah!


Of course I can work around it by copying the content, adding the text, deleting the old content, and replacing the node! But I would have thought xmlNodeAddContent would behave :o)


Regards,
                Jose.




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