Ockonal Ockonal - 8 months ago 87
C++ Question

XML file from internet and Qt

I want to parse some XML-file in Qt, but that file is located at some server in web. When I used QML I was able to use

class which takes address of file in internet (what I do need).

I have only one idea: use network request and download that xml directly. The idea is maybe there is a special interface in XML parser in qt which takes xml-path from internet?


As I know, you should download it. QHttp provides easy way to download it to a temporary file.

QTemporaryFile temp_file;
QHttp http("example.com");

New version (based on QNetworkAccessManager):

QNetworkAccessManager * manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(fileIsReady(QNetworkReply*)) );
void fileIsReady( QNetworkReply * reply)
  QTemporaryFile temp_file;