Unable to get attribute in XmlListModel
-
I am trying to display the current RSS feed: http://www.france24.com/en/top-stories/rss/
Made an XmlListModel
@ XmlListModel {
id: feedModel
source: "http://www.france24.com/en/top-stories/rss/"
query: "/rss/channel/item"XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "description"; query: "description/string()" } XmlRole { name: "img"; query: "thumbnail/@url/string()" } }@
However, if when i call img, it contains a blank string.
If i change the XmlRole like this
@XmlRole { name: "img"; query: "source/@url/string()" }@I get the url attribute from source. But dunno why i can't get url attribute from the thumbnail
-
Can you have copy of XML ? hope there 'thumbnail' and rest of the query path is path exist and correct.
-
bq. <thumbnail url="http://scd.france24.com/en/files/imagecache/france24_ct_api_medium2/article/image/20140910 marina silva.jpg"/>
<source url="http://scd.france24.com/en/files/imagecache/france24_ct_api_medium2/article/image/20140910 marina silva.jpg">AFP | Marina Silva campaigns in the Rocinha favela in Rio de Janeiro on August 30</source>Getting url from source can be done. I can't get url from thumbnail element
-
I used the same xml. I'm able to get it through thumbnail. Just pasting here on what I did. It may help you.
===qt.xml=========
@<?xml version="1.0" encoding="utf-8"?>
<current>
<thumbnail url="http://pthinks.france24.com/en/files/imagecache/france24_ct_api_medium2/article/image/20140910 marina silva.jpg"/>
<source url="http://scd.france24.com/en/files/imagecache/france24_ct_api_medium2/article/image/20140910 marina silva.jpg">AFP | Marina Silva campaigns in the Rocinha favela in Rio de Janeiro on August 30</source>
</current>@@XmlListModel { id: xmlModel source : "qt.xml" query: "/current" XmlRole { name: "ThumNail"; query: "thumbnail/@url/string()" } XmlRole { name: "Source"; query: "source/@url/string()" } Component.onCompleted: { console.log("XML Model loaded") } } ListView { id : showCity width: 180; height: 300 model: xmlModel delegate: Text { text: ThumNail + ": " + Source } }
@