[grilo-plugins] [flickr] Changed xmlRecoverDoc to xmlReadMemory
- From: Xabier Rodriguez Calvar <xrcalvar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] [flickr] Changed xmlRecoverDoc to xmlReadMemory
- Date: Tue, 4 May 2010 15:50:45 +0000 (UTC)
commit eeb6e6ba6dc3bdd31205da13f632f987ea8cb486
Author: Xabier Rodriguez Calvar <xrcalvar igalia com>
Date: Tue Apr 27 15:48:25 2010 +0200
[flickr] Changed xmlRecoverDoc to xmlReadMemory
skip_garbage_nodes is not usefull anymore as text nodes are already
removed.
src/flickr/gflickr.c | 23 ++++-------------------
1 files changed, 4 insertions(+), 19 deletions(-)
---
diff --git a/src/flickr/gflickr.c b/src/flickr/gflickr.c
index 4053542..00d264f 100644
--- a/src/flickr/gflickr.c
+++ b/src/flickr/gflickr.c
@@ -145,17 +145,6 @@ get_api_sig_photos_getInfo (GFlickr *f, glong photo_id)
return signature;
}
-static void
-skip_garbage_nodes (xmlNodePtr *node)
-{
- /* Result contains "\n" and "\t" to pretty align XML. Unfortunately, libxml
- doesn't cope very fine with them, and it creates "fakes" nodes with name
- "text" and value those characters. So we need to skip them */
- while ((*node) && xmlStrcmp ((*node)->name, (const xmlChar *) "text") == 0) {
- (*node) = (*node)->next;
- }
-}
-
static gboolean
result_is_correct (xmlNodePtr node)
{
@@ -202,7 +191,6 @@ get_photo (xmlNodePtr node)
/* Add children nodes with their properties */
node = node->xmlChildrenNode;
- skip_garbage_nodes (&node);
while (node) {
if (xmlStrcmp (node->name, (const xmlChar *) "owner") == 0 ||
@@ -216,7 +204,6 @@ get_photo (xmlNodePtr node)
}
node = node->next;
- skip_garbage_nodes (&node);
}
return photo;
@@ -230,7 +217,8 @@ process_photo_result (const gchar *xml_result, gpointer user_data)
GFlickrData *data = (GFlickrData *) user_data;
GHashTable *photo;
- doc = xmlRecoverDoc ((xmlChar *) xml_result);
+ doc = xmlReadMemory (xml_result, xmlStrlen ((xmlChar*) xml_result), NULL,
+ NULL, XML_PARSE_RECOVER | XML_PARSE_NOBLANKS);
node = xmlDocGetRootElement (doc);
/* Check result is ok */
@@ -238,7 +226,6 @@ process_photo_result (const gchar *xml_result, gpointer user_data)
data->get_info_cb (NULL, NULL, data->user_data);
} else {
node = node->xmlChildrenNode;
- skip_garbage_nodes (&node);
photo = get_photo (node);
data->get_info_cb (NULL, photo, data->user_data);
@@ -256,7 +243,8 @@ process_photolist_result (const gchar *xml_result, gpointer user_data)
xmlDocPtr doc;
xmlNodePtr node;
- doc = xmlRecoverDoc ((xmlChar *) xml_result);
+ doc = xmlReadMemory (xml_result, xmlStrlen ((xmlChar*) xml_result), NULL,
+ NULL, XML_PARSE_RECOVER | XML_PARSE_NOBLANKS);
node = xmlDocGetRootElement (doc);
/* Check result is ok */
@@ -264,15 +252,12 @@ process_photolist_result (const gchar *xml_result, gpointer user_data)
data->search_cb (NULL, NULL, data->user_data);
} else {
node = node->xmlChildrenNode;
- skip_garbage_nodes (&node);
/* Now we're at "photo pages" node */
node = node->xmlChildrenNode;
- skip_garbage_nodes (&node);
while (node) {
photolist = g_list_prepend (photolist, get_photo (node));
node = node->next;
- skip_garbage_nodes (&node);
}
data->search_cb (NULL, g_list_reverse (photolist), data->user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]