[Solved] Read different Feeds
-
Hi Pros there,
in my project YANET (Yet another News Ticker) I´ll try to access any different kind of News Feed to the Rss Reader Demo of Qt Quick but when try to read another Feed verion out of Rss2 like Atom or Rdf there is nothing to see. Here is what I´m coded:
@
...
XmlListModel {
function check() {
if(feedModel.count == 0)
{
console.log("No Xml Data found, try new Feed Model");
if(feedModel.query == "/rdf:RDF/item")
console.log("Can´t find any kind of known Rss Data");
else if(feedModel == "/feed/entry")
{
feedModel.query = "/rdf:RDF/item";
console.log("Test Rdf Model");
}
else if(feedModel.query == "/rss/channel/item")
{
feedModel.query = "/feed/entry";
console.log("Test Atom Model");
}
}
}
id: feedModel
source: "http://" + window.currentFeed
query: "/rss/channel/item"XmlRole { name: "title"; query: "title/string()" } XmlRole { name: "link"; query: "link/string()" } XmlRole { name: "description"; query: "description/string()" } onStatusChanged: { console.log(errorString()); if(status == XmlListModel.Ready) { check(); reload();} } }
...
@I added one line in CategoryDelegate to reset the feedModel.query line to "/rss/channel/item"
So now to my problem: If I try to read as example these atom feed: "heise.de/newsticker/heise-atom.xml":http://www.heise.de/newsticker/heise-atom.xml
I can´t see anything displayed, but the console log tells me that the feedModel.query string was changed!
Please help me
lynardo
-
Well I have a little bit experimented now, and found out that as far as I can see, it doesn´t work, because in the example feed there is this line: feed xmlns="http://www.w3.org/2005/Atom"
(I had to cut out the < and > because it wouldn´t be shown other way)
and if I cut out the attribute, that the line looks like this: <feed>
then it works. Although in "this":http://rss.chip.de/c/573/f/7439/index.rss Rss2 Feed it works with many of these attributes, does anyone know why??Really thank you!
lynardo
-
There seems to a property namespaceDeclarations which you need to set in the XmlListModel in this case. For Atom that is
@namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom';"@
Hartti
-
Forgot to add the url for the documentation about this
http://doc.qt.nokia.com/4.7/qml-xmllistmodel.html#namespaceDeclarations-propHartti