diff --git a/common.c b/common.c
index d0dd10b02f799b257be12c1261771e9e72072031..efc75700172da4d9887b69ca6a356f42881bf81a 100644
--- a/common.c
+++ b/common.c
@@ -102,10 +102,10 @@ leave:
return NULL;
}
-void xml_to_json(xmlNode *anode, struct json_object *jobj)
+void xml_to_json(xmlNode *anode, json_object *jobj)
{
xmlNodePtr cur_node = NULL;
- struct json_object *cur_jstr = NULL;
+ json_object *cur_jstr = NULL;
for (cur_node = anode; cur_node; cur_node = cur_node->next) {
debug_print("child address: %p\n", cur_node);
@@ -115,10 +115,7 @@ void xml_to_json(xmlNode *anode, struct json_object *jobj)
if (cur_node->type == XML_ELEMENT_NODE) {
if (xmlChildElementCount(cur_node) == 0) {
cur_jstr = json_object_new_string((char *)xmlNodeGetContent(cur_node));
-
- debug_print("xmlNodeGet name: %sn", (char *)cur_node->name);
- debug_print("xmlNodeGetContent: %sn", (char *)xmlNodeGetContent(cur_node));
-
+ debug_print("xmlNodeGet name: %s\n", (char *)cur_node->name);
json_object_object_add(jobj, (char *)cur_node->name, cur_jstr);
}
}
@@ -130,13 +127,14 @@ void xml_to_json(xmlNode *anode, struct json_object *jobj)
//free memory...
struct json_object *xml_to_json_converter(struct write_result *result)
{
- struct json_object *jobj;
+ json_object *jobj;
xmlDocPtr doc_ptr = NULL;
xmlNode *origin_node = NULL;
doc_ptr = xmlParseMemory(result->data, result->pos);
if (!doc_ptr)
goto fail_doc_ptr;
+ debug_print("data from xml: %s\n", result->data);
origin_node = xmlDocGetRootElement(doc_ptr);
if (!origin_node)
@@ -145,12 +143,10 @@ struct json_object *xml_to_json_converter(struct write_result *result)
jobj = json_object_new_object();
xml_to_json(origin_node, jobj);
- debug_print("The json object created: %s\n", json_object_to_json_string(jobj));
+ debug_print("Json object from xml: %s\n", json_object_to_json_string(jobj));
if (doc_ptr)
xmlFreeDoc(doc_ptr);
- if (origin_node)
- free (origin_node);
return jobj;