Re: [xml] problem in using xmlAddChildList - need help



My idea would be that either you or I is confused about the
differences between XPath lists, as represented by an xmlNodeSetPtr,
and "list of nodes", as expected by xmlAddChildList.

Bill

Senthil Nathan wrote:
Any idea on this problem would be really helpful.

Thanks
Senthil Nathan R


On 2/14/08, Senthil Nathan <rsennat gmail com> wrote:

Hi All,
I'm trying to use xmlAddChildList( ) and seems there is a strange
problem
in adding this
child list to the doctree (xmlDocPtr).

here is the code snippet which creates the problem.


bool AddChild(const string &path, xmlNodePtr *node*, AddChildType
addType)
{
...............assume after evaluating the path, i have a
xmlNodeSetPtr
nodes;
    xmlNodePtr pnode = nodes->nodeTab[0];
    switch (addType)
    {
    case eAddNode:
        break;
    case eAddNodeList:
.............assume we have the xmlDocPtr tree;
        //xmlElemDump(stdout, tree, pnode); ----> this shows
proper data
of *node.*
        if (xmlAddChildList(pnode, node) == NULL) ----------->
this adds
the child list but the data is duplicated again for every

call of this function with a new nodelist
        {
            return false;
        }
        //xmlElemDump(stdout, tree, pnode); ----> this doesnt show
proper
data of *pnode.
*        //xmlFreeNodeList(node);
        break;
    default:
        break;
    }
    return true;
}

for example, if I call this function with xmlNodePtr node has the
data as,
1st call : <childList1>......</childList1>
2nd call: <childList2>......</childList2>
3rd call: <childList3>......</childList3>

now after this execution, the actual docTree has the info as
follows,
<childList1>......</childList1>
 <childList2>......</childList2>
<childList1>......</childList1>
 <childList3>......</childList3>
<childList1>......</childList1>
 <childList2>......</childList2>
<childList1>......</childList1>

but this should have added only once. Somehow the data gets
duplicated
after
xmlAddChildList( ). because the *node contains the proper data*.
only the
*pnode*
*is having the wrong data.*

could you please help me on to figure out the problem or fix it.

Thanks
Senthil Nathan R

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml






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