handles empty correctly

This commit is contained in:
Kyle Maxwell 2009-02-24 15:54:43 -08:00
parent 9033719cf0
commit 19833a4124
3 changed files with 17 additions and 6 deletions

View File

@ -99,6 +99,11 @@ unlink(xmlNodePtr xml) {
}
}
static bool
is_root(xmlElementPtr xml) {
return xml != NULL && xml->name != NULL && xml->prefix !=NULL && !strcmp(xml->name, "root") && !strcmp(xml->prefix, "dexter");
}
static void
prune(parsedDexPtr ptr, xmlNodePtr xml, char* err) {
if(xml == NULL) return;

View File

@ -1 +1 @@
{}
{ }

View File

@ -3,10 +3,7 @@
#include "xml2json.h"
#include <string.h>
/**
* Handles a simplified xml
*/
struct json_object * xml2json(xmlNodePtr xml) {
static struct json_object * _xml2json(xmlNodePtr xml) {
if(xml == NULL) return NULL;
xmlNodePtr child;
@ -39,4 +36,13 @@ struct json_object * xml2json(xmlNodePtr xml) {
break;
}
return json;
}
}
/**
* Handles a simplified xml
*/
struct json_object * xml2json(xmlNodePtr xml) {
struct json_object * json = _xml2json(xml);
if(json == NULL) json = json_object_new_object();
return json;
}