#include #include #include QByteArray readFile(const QString &file_path) { QFile input_file(file_path); QByteArray input_data; if (input_file.open(QIODevice::Text | QIODevice::Unbuffered | QIODevice::ReadOnly)) { input_data = input_file.readAll(); input_file.close(); return input_data; } else { return {}; } } QString xmlMessageRawContents(const QDomElement &msg_element) { QString raw_contents; QTextStream str(&raw_contents); msg_element.save(str, 0, QDomNode::EncodingPolicy::EncodingFromTextStream); return raw_contents; } int main(int argc, char *argv[]) { QByteArray xml = readFile("default.rss"); QDomDocument doc; doc.setContent(xml); QDomNodeList items = doc.namedItem("rss").namedItem("channel").toElement().elementsByTagName( "item"); qDebug() << items.size(); QElapsedTimer tmr; for (int i = 0; i < items.size(); i++) { QDomElement message_item = items.item(i).toElement(); tmr.restart(); QString raw_message = xmlMessageRawContents(message_item); qDebug() << "elapsed " << tmr.elapsed() << " ms"; } return 0; }