Parsing RSS Feeds by XmlListModel
It's true that we now have categories, but they don't seem to be involved with RSS at all. Also, if you dig deeper, you'll find that the RSS feeds are in fact the XML documents. Qt already provides a useful type to help us parse them. We don't need to reinvent the wheel. This powerful type is the so-called XmlListModel
element and it uses XmlRole
to query.
Firstly, we need to expose the url
role of categoriesModel
to the main scope. This is done by declaring the property storing the model's current element, url
, inside ListView
. Then, we can add an XmlListModel
element and use that url
element as its source
. Accordingly, the modified main.qml
file is pasted here:
import QtQuick 2.3 import QtQuick.Window 2.2 import QtQuick.XmlListModel 2.0 import "qrc:/" Window { id: mainWindow visible: true width: 720 height: 400 Feeds { id: categoriesModel } ListView { id: categories width: 150 height: parent...