语言

Menu
Sites
Language
How XML data parse from array and display into list view

Hello,

I fetched http data from URL using CURL and get in into array...but my objective display data in list view any one please help me with example...

Here I attached my sample code...

 

void printParsedList(Eina_List * jsonlist, int level)
{

    Eina_List *l;
    void *list_data;
    int i=0;
    EINA_LIST_FOREACH(jsonlist, l, list_data)
    {
       ......

      ......
    }
    eina_list_free(jsonlist);

}

 

static void parseArray_clicked_cb(void *data)
{
    JsonParser *jsonParser;
    jsonParser = json_parser_new ();
    guint nested_objects = G_N_ELEMENTS (data);
    LOGI("ParseNestedObjects size %d",n_test_nested_objects);
    for (int i = 0; i < nested_objects; i++)
    {
        GError *error = NULL;

        if (!json_parser_load_from_data (jsonParser, data[i], -1, &error))
        {
            LOGI("ParseNestedObjects Error");
            g_error_free (error);
        }
        else
        {
            int level =1;
            Eina_List *jsonList = NULL;
            jsonList =ParseJsonEntity(json_parser_get_root (jsonParser),false);
            printParsedList(jsonList,level);
        }
    }
    g_object_unref(jsonParser);
}

Required  XML to list view from array buf[].

 

 

 

编辑者为: A.T.M. Alaul Haque 24 6月, 2015

响应

4 回复
John Ixion

Hi,

we have this tutorial https://developer.tizen.org/documentation/articles/native-application-dev-tip-tutorial-json-parser

Alex Dem

Hi,
Do you mean how to create UI based on parsed json tree? For example, how to construct naviframe with elm_list and on click of every elm_list item another elm_list should be opened, and all items - are nodes from json tree? Something like this?
If so - I did not face with ready example for 2.3.0 (as I remeber it was for 2.2.1). But I think it should be possible.
Alexey.

colin Rao

Hi,

Possible the sample code "UI Controls(elementary) sample applicaton" can help you.

IDE > File > New > Tizen Native Project > Sample > UI Controls(elementary) sample applicaton

It's main ui is just a list view, check the function "create_list_view" in main.c 

As your sample code:

    Evas_Object *list;
    Evas_Object *btn;
    Evas_Object *nf = ad->nf;
    Elm_Object_Item *nf_it;

    list = elm_list_add(nf);
    elm_list_mode_set(list, ELM_LIST_COMPRESS);
    evas_object_smart_callback_add(list, "selected", list_selected_cb, NULL);

    EINA_LIST_FOREACH(jsonlist, l, list_data)
    {
       elm_list_item_append(list, "your list item data", NULL, NULL, bg_cb, nf);

      ......
    }

Jean Yang

Hi ,

 

Just add one more tip, you can also have look at genlist.c at IDE > File > New > Tizen Native Project > Sample > UI Controls(elementary) sample applicaton