Parse xml response to multiple views



  • Good day all,

    I have an xml response that looks like the following

    @ <menu>
    <menu_name>name1</menu_name>
    <menu_items>
    <item>
    <item_name>.......</item_name>
    <description>description .............</description>
    <thumb>http://........</thumb>
    ..............
    </item>
    ............................
    </menu_items>
    </menu>
    <menu>
    <menu_name>name2</menu_name>
    <menu_items>
    <item>
    <item_name>.......</item_name>
    <description>description .............</description>
    <thumb>http://........</thumb>
    ..............
    </item>
    ............................
    </menu_items>
    </menu>@

    What I want to know is what is the easiest way to parse this response so that I can have a view of list of menus, and when clicking on a menu name, a view of menu items will show.

    XmlListModel cant do the job as needed because of multiple levels of xml structure, I'm thinking of doing a regular parsing inside

    @function doRequest(...)
    {
    var doc = new XMLHttpRequest();
    .........
    doc.onreadystatechange = function() {
    ......
    var a = doc.responseXML.documentElement;
    for (var ii = 0; ii < a.childNodes.length; ++ii) {
    //do parsing of menu and menu items inside here
    }
    }@

    my problem with the above solution is the way I will maintain the structure of the response so i can use it on different views
    I'm open to other ideas or solutions
    Thanks a lot :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.