I have a Qt application where I am trying to download a XML file form a server and then read the content of the file.
Unfortunately, I am not able to get the content of the downloaded file in to a QDomDocument
.
This is what I tried
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(fileIsReady(QNetworkReply*)) );
manager->get(QNetworkRequest(QUrl("http://example.com/file.xml")));
fileIsReady(QNetworkReply *reply){
QTemporaryFile tempFile;
if(tempFile.open()){
tempFile.write(reply->readAll());
QDomDocument versionXML;
QDomElement root;
if(!versionXML.setContent(&tempFile)){
qDebug() << "failed to load version file" << endl;
}
else{
root=versionXML.firstChildElement();
//...
}
}
}
How can I achieve this?