Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Downloading XML file
Abdeljalil last edited by
i want to get a XML file from online source,
how can i download it and store the data in QTemporaryFile or pass it directly to QXmlStreamReader
i tried a lot but i dont know what is the problem exactly
int main(int argc, char *argv)
QCoreApplication a(argc, argv);
QNetworkAccessManager manager = new QNetworkAccessManager ;
QNetworkReply reply = manager->get( request) ;
QXmlStreamReader reader( reply );
QNetworkAccessManager works asynchronously. That means that at line 7 in your code, the reply is still empty. You need to wait for "finished":http://qt-project.org/doc/qt-5/qnetworkaccessmanager.html#finished signal to be emitted by QNAM, and then proceed to save/ parse the reply, check for errors, etc.
This is best done by introducing a new class, with a slot defined and connected to QNAM::finished() singal. The main routine is not a good place to do it, although it is still possible.