I have tried to use both xmlRemoveProp and xmlUnsetProp to
remove an element and both return an error stating they can’t find the
element, even though it was found with xmlStrcmp. So not sure what I’m doing wrong, any suggestions
would be appreciated. xmlNodePtr
cur1 = xmlDocGetRootElement(fDoc); if
(cur1 == NULL) throw
runtime_error("Config::removeConfig: error parsing config file " +
fConfigFile); xmlNodePtr
cur2; xmlAttrPtr
element; cur1
= cur1->xmlChildrenNode; while
(cur1 != NULL) { if
(xmlStrcmp(cur1->name, (const xmlChar *)section.c_str()) == 0) { cur2
= cur1->xmlChildrenNode; while
(cur2 != NULL) { if
(xmlStrcmp(cur2->name, (const xmlChar*)name.c_str()) == 0) { element
= xmlHasProp(cur2, (const xmlChar*)name.c_str()); if
( element == NULL ) throw
runtime_error("Config::removeConfig: xmlHasProp error"); xmlRemoveProp(element); // if
( xmlUnsetProp(cur2, (const xmlChar*)name.c_str()) != 0 ) // throw
runtime_error("Config::removeConfig: xmlUnsetProp error"); return; } cur2
= cur2->next; } } cur1
= cur1->next; } David Hill |