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. QML: Using two XmlListModel elements for a single request
Qt 6.11 is out! See what's new in the release blog

QML: Using two XmlListModel elements for a single request

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 4.0k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    artem.marchenko
    wrote on last edited by
    #1

    Hi

    I am playing with flickr APIs from QML/JavaScript. All the communication to the server happens via REST/XML and I use XmlListModel element for parsing the results. The problem is that requests can sometimes fail (e.g. authorization expired) and before extracting the actual data I need to check the error code in the very first element of XML. Depending on the error code the rest of the XML should be processed via one or another XmlListModel.

    Is there a way to parse the same request several times with the help of different models?
    I wouldn't like to issue a second request just to be able to process the same result in a different way.

    Cheers,
    Artem.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kxyu
      wrote on last edited by
      #2

      you can download your data with XMLHttpRequest, then check, and then pass it to proper XmlListModel's xml property

      1 Reply Last reply
      0
      • A Offline
        A Offline
        artem.marchenko
        wrote on last edited by
        #3

        Oh, I didn't realize you can fill the model without using the source. Thanks for the hint!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          artem.marchenko
          wrote on last edited by
          #4

          Forgot to comment on it.
          Tried, works, thanks!

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cmer4
            wrote on last edited by
            #5

            Hi guys, could you please clarify how do you actually "pass it to proper XmlListModel’s xml"?
            I tried to xmllistmodel.xml=xhr.responseXml and it doesn't work (error: can't assign undefined to qstring...( )

            1 Reply Last reply
            0
            • C Offline
              C Offline
              cmer4
              wrote on last edited by
              #6

              tried xmllistmodel.xml=xhr.responseXml.toString() as well no success...

              What is the trick??? Please help!

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cmer4
                wrote on last edited by
                #7

                hmm seems like I missed something and the solution was just to use responseText thingy...

                I guess it is...sorry folks

                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