fixed pruning of empty strings
This commit is contained in:
parent
8a759cb73d
commit
491a65531f
13
dexter.c
13
dexter.c
|
@ -122,13 +122,24 @@ visit(parsedDexPtr ptr, xmlNodePtr xml, bool bubbling) {
|
|||
xmlNodePtr child = xml->children;
|
||||
xmlNodePtr parent = xml->parent;
|
||||
if(parent == NULL) return;
|
||||
if(child == NULL) prune(ptr, xml, NULL);
|
||||
if(xml_empty(xml)) prune(ptr, xml, NULL);
|
||||
while(!bubbling && child != NULL){
|
||||
visit(ptr, child, bubbling);
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
xml_empty(xmlNodePtr xml) {
|
||||
xmlNodePtr child = xml->children;
|
||||
while(child != NULL) {
|
||||
if(child->type != XML_TEXT_NODE) return false;
|
||||
if(strlen(child->content)) return false;
|
||||
child = child->next;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
parsedDexPtr dex_parse_doc(dexPtr dex, xmlDocPtr doc) {
|
||||
parsedDexPtr ptr = (parsedDexPtr) calloc(sizeof(parsed_dex), 1);
|
||||
ptr->dex = dex;
|
||||
|
|
1
dexter.h
1
dexter.h
|
@ -90,5 +90,6 @@ static char* inner_key_of(struct json_object *);
|
|||
static char* inner_key_each(struct json_object *);
|
||||
|
||||
static void visit(parsedDexPtr ptr, xmlNodePtr xml, bool bubbling);
|
||||
static bool xml_empty(xmlNodePtr xml);
|
||||
|
||||
#endif
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue