QML: Using two XmlListModel elements for a single request

  • 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.


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

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

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

  • 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...( )

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

    What is the trick??? Please help!

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

    I guess it is...sorry folks

Log in to reply