| 226 | //Check the type of the feed |
| 227 | QString rootName = domDoc.documentElement().nodeName(); |
| 228 | if(rootName == QString::fromLatin1("rss") || |
| 229 | rootName == QString::fromLatin1("rdf:RDF")) { |
| 230 | parseRSS(domDoc); |
| 231 | xmlFile.close(); |
| 232 | return; |
| 233 | } |
| 234 | else if (rootName == QString::fromLatin1("feed")) { |
| 235 | parseAtom(domDoc); |
| 236 | xmlFile.close(); |
| 237 | return; |
| 238 | } |
| 239 | else { |
| 240 | VERBOSE(VB_IMPORTANT, "MythNews: NewsEngine: XML-file is not valid RSS-feed"); |
| 241 | m_errorString += tr("XML-file is not valid RSS-feed"); |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | } |
| 246 | |
| 247 | void NewsSite::parseRSS(QDomDocument domDoc) |
| 248 | { |
| 375 | QDomNode itemNode; |
| 376 | QString title, description, url, thumbnail, mediaurl, enclosure, imageURL, enclosure_type; |
| 377 | for (unsigned int i = 0; i < entries.count(); i++) { |
| 378 | itemNode = entries.item(i); |
| 379 | title = itemNode.namedItem(QString::fromLatin1("title")).toElement().text().simplifyWhiteSpace(); |
| 380 | if (!title.isNull()) |
| 381 | ReplaceHtmlChar(title); |
| 382 | |
| 383 | QDomNode summNode = itemNode.namedItem(QString::fromLatin1("summary")); |
| 384 | if (!summNode.isNull()) |
| 385 | { |
| 386 | description = summNode.toElement().text().simplifyWhiteSpace(); |
| 387 | ReplaceHtmlChar(description); |
| 388 | } |
| 389 | else |
| 390 | description = QString::null; |
| 391 | |
| 392 | QDomNode linkNode = itemNode.namedItem(QString::fromLatin1("link")); |
| 393 | if (!linkNode.isNull()){ |
| 394 | QDomAttr linkHref = linkNode.toElement().attributeNode("href"); |
| 395 | if(!linkHref.isNull()) |
| 396 | url = linkHref.value(); |
| 397 | } |
| 398 | else |
| 399 | url = QString::null; |
| 400 | |
| 401 | new NewsArticle(this, title, description, url, QString::null, QString::null, QString::null); |
| 402 | } |