typedef QMap<int, QStringList> RssParams;
/* read a static rss version 1/2 file and return QMap params of link title description */
RssParams ReadRssFile
( QString fileplace ,
int limiter
){
RssParams contingent;
QFile xmlfile
( fileplace
);
int errorLine, errorColumn, position;
position = 0 -1;
return contingent;
}
if (!doc.setContent(&xmlfile,true, &errorStr, &errorLine, &errorColumn)) {
xmlfile.close();
return contingent;
}
QDomElement chanelbase
= root.
firstChildElement("channel");
QDomElement child
= chanelbase.
firstChildElement("item");
while (!child.isNull()) {
QString title
= child.
firstChildElement("title").
text();
QString desc
= child.
firstChildElement("description").
text();
QString urirss
= child.
firstChildElement("link").
text();
if (!title.isEmpty() and !desc.isEmpty() and !urirss.isEmpty()) {
position++;
if (position < limiter) {
contingent.
insert(position,
QStringList() << urirss << title
)<< desc
);
}
}
child = child.nextSiblingElement("item");
}
xmlfile.close();
return contingent;
}
typedef QMap<int, QStringList> RssParams;
/* read a static rss version 1/2 file and return QMap params of link title description */
RssParams ReadRssFile( QString fileplace , int limiter )
{
RssParams contingent;
QFile xmlfile( fileplace );
QString errorStr, obname, inhalt;
int errorLine, errorColumn, position;
position = 0 -1;
QDomDocument doc("RSS");
if(!xmlfile.open( QIODevice::ReadOnly ) ) {
return contingent;
}
if (!doc.setContent(&xmlfile,true, &errorStr, &errorLine, &errorColumn)) {
xmlfile.close();
return contingent;
}
QDomElement root = doc.documentElement();
QDomElement chanelbase = root.firstChildElement("channel");
QDomElement child = chanelbase.firstChildElement("item");
while (!child.isNull()) {
QString title = child.firstChildElement("title").text();
QString desc = child.firstChildElement("description").text();
QString urirss = child.firstChildElement("link").text();
if (!title.isEmpty() and !desc.isEmpty() and !urirss.isEmpty()) {
position++;
if (position < limiter) {
contingent.insert(position,QStringList() << urirss << title)<< desc);
}
}
child = child.nextSiblingElement("item");
}
xmlfile.close();
return contingent;
}
To copy to clipboard, switch view to plain text mode
Bookmarks