Hi ,
I'm facing problem with ezxml_cut function. and using ezxml-0.8.6 version.
when we try to remove node, it is not removing selected node instead it's removing below nodes.
void load_xml(ezxml_t root){
char *xml = ezxml_toxml(root);
printf("%s\n", xml);
free(xml);
}
int main(int argc, char **argv)
{
if (argc < 2){
printf("usage: ./test ");
exit(1);
}
int flag=0;
const char str=NULL;
char p=NULL;
ezxml_t root = ezxml_parse_file(argv[1]);
ezxml_t get_child_tmp1;
get_child_tmp1 = ezxml_child(root,"LANDevice");
p = get_child_tmp1->child;
while( get_child_tmp1->child != NULL){
printf("%s\n",ezxml_name(get_child_tmp1->child));
if (!strcmp(ezxml_name(get_child_tmp1->child),"WLANConfiguration")){
if(flag == 0){
str = ezxml_attr(get_child_tmp1->child,"instance");
if(!(strcmp(str,"3"))){
ezxml_cut(get_child_tmp1->child); /trying to delete node 3 of WLANConfiguration
flag=1;
}
}
}
get_child_tmp1->child = get_child_tmp1->child->ordered;
}
get_child_tmp1->child = p;
load_xml(get_child_tmp1);
return 0;
}
Can you please find attached input_out_xml.txt file for input and expected output info and help me to solve this problem or is anything wrong with my code
got the solution, we need to traverse top level node by node instead of taking node and traversing and removing.
thanks for not replying.