From: Andrea Zagli Date: Sun, 30 Dec 2012 17:45:08 +0000 (+0100) Subject: libxml parsing retrieved service document. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=d3494e3b801ef75601cf39a4cf87b55f8db8a21b;p=libgapp libxml parsing retrieved service document. --- diff --git a/src/service.c b/src/service.c index 8a0187a..80a1d0d 100644 --- a/src/service.c +++ b/src/service.c @@ -140,10 +140,26 @@ GappService if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { g_message ("Message GET: success (%d).", msg->status_code); + + priv->xdoc = xmlParseDoc ((const xmlChar *)msg->response_body->data); + if (priv->xdoc == NULL) + { + g_warning ("Unable to parse xml."); + g_object_unref (service); + service = NULL; + } + else + { + priv->xroot = xmlDocGetRootElement (priv->xdoc); + } } else { - g_message ("Message GET: error (%d).", msg->status_code); + g_warning ("Message GET: error (%d): %s.", + msg->status_code, + msg->reason_phrase); + g_object_unref (service); + service = NULL; } return service; @@ -158,21 +174,9 @@ GappService xmlDoc *gapp_service_get_xml_doc (GappService *service) { - xmlNode *xnode; - GList *lst; - GappServicePrivate *priv = GAPP_SERVICE_GET_PRIVATE (service); - xmlDoc *xdoc = xmlNewDoc ((const xmlChar *)"1.0"); - xmlNode *xroot = xmlNewNode (NULL, (const xmlChar *)"feed"); - - /* adding root element */ - if (xroot == NULL) return NULL; - - xmlNewNs (xroot, (const xmlChar *)"http://www.w3.org/2005/Atom", NULL); - xmlDocSetRootElement (xdoc, xroot); - - return xdoc; + return priv->xdoc; } /** diff --git a/tests/service.c b/tests/service.c index 3b0899d..9a548a9 100644 --- a/tests/service.c +++ b/tests/service.c @@ -8,6 +8,10 @@ main (int argc, char *argv[]) GappService *service; service = gapp_service_new (argv[1]); + if (service != NULL) + { + gapp_service_save_file (service, "service_test.xml"); + } return 0; }