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 <xml file=""> ");
exit(1);
}</xml>
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;
}
<internetgatewaydevice>
<landevice instance="1">
<lanethernetinterfacenumberofentries>4</lanethernetinterfacenumberofentries>
<lanethernetinterfacenumberofentries1>5</lanethernetinterfacenumberofentries1>
<lanusbinterfacenumberofentries>1</lanusbinterfacenumberofentries>
<lanwlanconfigurationnumberofentries>1</lanwlanconfigurationnumberofentries>
<x__lanmocainterfacenumberofentries>0
<lanhostconfigmanagement>
<dhcpconditionalservingpool instance="7">
<enable>TRUE</enable>
<manualadd>0</manualadd>
<chaddr>00:27:13:b7:5d:63</chaddr>
<reservedaddresses>192.168.0.8</reservedaddresses>
</dhcpconditionalservingpool>
</lanhostconfigmanagement>
<lanusbinterfaceconfig nextinstance="2"></lanusbinterfaceconfig>
<wlanconfiguration instance="1">
<enable>FALSE</enable>
<maxbitrate>Auto</maxbitrate>
<basicencryptionmodes>None</basicencryptionmodes>
</wlanconfiguration>
<wlanconfiguration instance="2">
<enable>FALSE</enable>
<maxbitrate>Auto</maxbitrate>
<basicencryptionmodes>None</basicencryptionmodes>
</wlanconfiguration>
<wlanconfiguration instance="3"> =======> expectation this node gets deleted but below nodes are getting deleleted (i.e from <wlanconfiguration instance="4"> onwards all the nodes are getting deleted.) why ?
<enable>FALSE</enable>
<maxbitrate>Auto</maxbitrate>
<basicencryptionmodes>None</basicencryptionmodes>
</wlanconfiguration>
<wlanconfiguration instance="4">
<enable>FALSE</enable>
<maxbitrate>Auto</maxbitrate>
<basicencryptionmodes>None</basicencryptionmodes>
</wlanconfiguration>
<wlanconfiguration instance="5">
<enable>FALSE</enable>
<maxbitrate>Auto</maxbitrate>
<basicencryptionmodes>None</basicencryptionmodes>
</wlanconfiguration>
<wlanconfiguration nextinstance="6"></wlanconfiguration>
<hosts>
<host nextinstance="14"></host>
</hosts>
<x_00247b_alg instance="1">
</x_00247b_alg>
<x_00247b_alg nextinstance="2"></x_00247b_alg>
</wlanconfiguration></x__lanmocainterfacenumberofentries></landevice>
</internetgatewaydevice>
Can you please help me to achieve above scenarios or is anything wrong with my code.
please refer "12 ezxml_cut not functioning properly_modified ticket", since this ticket has formatting and less info about the problem.
please ignore this ticket.