fixed pruning of empty strings

This commit is contained in:
Kyle Maxwell 2009-02-23 15:25:47 -08:00
parent 8a759cb73d
commit 491a65531f
3 changed files with 14 additions and 2 deletions

View File

@ -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;

View File

@ -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