Languages

Menu
Sites
Language
Problem with Data Parsing

Hello developers,

I am having some trouble parsing an RSS feed. I am using the LibXML2 sample app for this work. I can see the xml file on the sdb shell, however I don't know how to get the data from the feed to show up on my app. Any help would be appreciated.

Responses

6 Replies
Shaswati Saha

Hello,
Here's a way to create and read xml file using libxml. You can go through the link below: 
https://developer.tizen.org/ko/community/code-snippet/native-code-snippet/createread-xml-file-libxml2?tab=tags-all&langredirect=1

Moreover, I would like to suggest you to go through the "
get_data_from_node" method in the user_callbacks file of the app you've mentioned above to get an idea how to extract specified data from XML nodes.

Thanks.
 

Arnob Chowdhury

Thank you for your help.

Arnob Chowdhury

Hello Developers,

I tried to implement the code snippet provided in the last post, but I am getting 18 errors when I try to run the code. Most of the errors were 'undeclared identifier"

I am a newbie to app development and a novice programmer. I must be making some very basic coding mistakes. I would really appreciate all of the developer's patience and help.

The app I am using is the online sample app included in the Tizen IDE "LibXML2".

These are the screenshots from the sdbshell for my LibXML2 sample app for the rss feed.

https://postimg.org/image/j8gszvhi9/

https://postimg.org/image/yv82d8va9/

https://postimg.org/image/bv1f0wxgh/

https://postimg.org/image/r51a83syp/

https://postimg.org/image/69ezwuwrl/

I am trying to parse this RSS feed from the Pacific Disaster Center website:

http://d2mxabrykbl1km.cloudfront.net/feed.xml

 

Shaswati Saha

Hello,
I've implemented the same thing you're trying to do. I followed the way in the link below. Please  have a look.
http://www.developer.com/xml/article.php/3729826/Libxml2-Everything-You-Need-in-an-XML-Library.htm
 

I think the libxml2 sample will be difficult to understand for now. So, forget about that and simply open a basic UI online sample and try implenting the way in the above link.

I've done a simple modification in print_element_names method to show the content of the tag  <title>  in a label of my app. I think you'll be able to show other data as per your requirements in the same way. Please have a look.

 

static void print_element_names(void *data , xmlDocPtr doc, xmlNode * a_node)
{

    appdata_s *ad = data;
    xmlNode *cur_node = NULL;

	xmlChar *key;
	for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
		if (cur_node->type == XML_ELEMENT_NODE) {
			if ((!xmlStrcmp(cur_node->name, (const xmlChar *)"title"))) {
				key = xmlNodeListGetString(doc, cur_node->xmlChildrenNode, 1);

				ad->label = elm_label_add(ad->conform);
				elm_object_text_set(ad->label, key);
				evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
				elm_object_content_set(ad->conform, ad->label);
				xmlFree(key);
			}
		}

		print_element_names(ad, doc,cur_node->children);
	}
}

 

Arnob Chowdhury

Ok, then I'll start a new project with BasicUI and give it a shot.

Shaswati Saha

Please post here if you find any kind of difficulties regarding the requirement.

Regards.