Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Parse xml response to multiple views
QtWS25 Last Chance

Parse xml response to multiple views

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 892 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yazwas
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved