×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    89

    "QML XmlListModel" how to parse a local xml file?

    Usually, we say
    Code:
        XmlListModel {
            id: aModel
            source: "content/source.xml"
            query: "/rss/channel/item"
    
            XmlRole { name: "title"; query: "title/string()" }
            XmlRole { name: "link"; query: "link/string()" }
        }
    
            ListView {
                id: list
                width: parent.width; height: window.height
                model: aModel
                delegate: Text {
                    text: "title is: " + title;
                }
            }
    I've got the XmlListModel status 1 (ready), but there is nothing on screen. Why?
    Last edited by useryy2; 2011-07-07 at 09:19.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: "QML XmlListModel" how to parse a local xml file?

    can you show your xml file or sample of that ??

  3. #3
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    89

    Re: "QML XmlListModel" how to parse a local xml file?

    Hi gaba88,

    The xml file is as following. Also I've uploaded the whole project here

    =========================================
    <?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0">
    <channel>
    <item>
    <title>A blog post</title>
    <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
    </item>
    <item>
    <title>Another blog post</title>
    <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
    </item>
    </channel>
    </rss>

  4. #4
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    89

    Re: "QML XmlListModel" how to parse a local xml file?

    Quote Originally Posted by useryy2 View Post
    Hi gaba88,

    The xml file is as following. Also I've uploaded the whole project here

    =========================================
    <?xml version="1.0" encoding="utf-8"?>
    <rss version="2.0">
    <channel>
    <item>
    <title>A blog post</title>
    <pubDate>Sat, 07 Sep 2010 10:00:01 GMT</pubDate>
    </item>
    <item>
    <title>Another blog post</title>
    <pubDate>Sat, 07 Sep 2010 15:35:01 GMT</pubDate>
    </item>
    </channel>
    </rss>
    I've found something, here are 2 sources, source3 is OK. source4 is Not ok. But I can't tell the difference.

  5. #5
    Registered User
    Join Date
    Jul 2011
    Posts
    4

    Re: "QML XmlListModel" how to parse a local xml file?

    Hi,

    I've tried the exact same example, but I can't get it to work. The screen is blank and I don't see any elements. I also tried downloading your project, but it didn't work for me either. The 2 sources you told about had at least one difference: in source3 there is no space before the xml tag but in source 4 there is. Anyway, neither worked for me. Do you have any ideas how to get it to work?

    Best regards,

    Sebastian

  6. #6
    Regular Contributor
    Join Date
    Apr 2011
    Posts
    89

    Re: "QML XmlListModel" how to point a local xml file for "source" property?

    Hi SBockelman,
    Have you really tried my project. At least "XmlListModel test" should be displayed instead of "blank screen".

    If you do do it, pls check the "application output" at the bottom of Qt Creator for other errors.

    Further information is needed for suggestion.

  7. #7
    Registered User
    Join Date
    Jul 2011
    Posts
    4

    Re: "QML XmlListModel" how to point a local xml file for "source" property?

    Hi,

    I found the same example somewhere else before and didn't get it to work, then I found your post with the exact same problem. I tried your code before and didn't get it to work. However now when I tried it I got it to work!
    I switched source3.xml to the place where the source.xml was and renamed it to source.xml. Then when I run it, it showed me "XmlListModel test" and application output was "other status: 2
    status: ready" but I couldn't see any of the content from the XML.
    Then I modified the QML a bit (I'm new to QML..) so I had this:

    Code:
        Rectangle{
            anchors.fill: parent
            /*
            Text{
                id:txt
                anchors.top: parent.top
                text: "XmlListModel test"
            }
            */
            ListView{
                id: viewer
                //anchors.top: txt.bottom
                anchors.fill: parent
                model: modeler
                delegate: Text{ text: "title is " + title}
            }
        }
    After that I could see the content from the XML-file.

    Before whern I tried your example I guess the QML just caused that I couldn't see anything.
    A few days ago I just put the XML on a server instead when I couldn't get it to work locally, but it's nice this solved the real problem instead of just avoiding the symptoms!
    It makes it easier to debug stuff when one doesn't have to put the XML on the server every time.

    Thanks for your help!

    Best regards,

    Sebastian

Similar Threads

  1. How to call/load another QML file from QML ?
    By cadlg in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-07-28, 09:15
  2. How to use QFileDialog or another way for file browsing in QML UI ?
    By magpielover in forum [Archived] Qt Quick
    Replies: 3
    Last Post: 2011-05-12, 08:04
  3. How to load local XML file in Flash Lite that is embedded in a WRT Widget?
    By kvirtanen in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2010-04-06, 10:14
  4. Read local xml file
    By mic3000 in forum Symbian Web Runtime
    Replies: 8
    Last Post: 2010-01-20, 15:22
  5. Browser plug-in for local file system access + for none open source
    By qmei in forum Mobile Web Site Development
    Replies: 2
    Last Post: 2008-08-20, 08:41

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •