I wish to use QtWebKit to load a url for display, but, that's the easy part, I can do that. What I wish to do is record / log xml as I go. My attention here is to record and database certain details on the fly, by recording those details.
My problem is, how to do this all on the fly, without requesting the same url from the server twice, once for the xml, and the second time to view the url.
My hope here, is to implement a very fast way of recording set data as the user passes over it. Take for example, rather then have to type out details displayed by a website, I wish to have those details chucked into a database as I the user views the website.
Now, I am using QtWebKit, and I have everything pretty much solved viewing wise. I have a loadUrl() routine which calls load(url) inside the qwebview.h
The problem is, how do I piggyback xml parsing on top of this?
In your loadUrl do the download of the url yourself using the HTTP download facilities Qt already provides (QNetworkRequest and friends).
Once you got the data, parse and log it and use:
void QWebView::setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )
To set it into the QWebView manually. The second url parameter is the url you have, which will be used as a base url for the elements that are referenced from the page.
If you are not sure you downloaded html, then use:
void QWebView::setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )
You can also do the inverse. Just call QWebView::load(url) in your method, and once the transfer is complete, use QWebView::mainFrame() to get the main frame and then QWebFrame::toHtml() to get the content, which you can parse and log as you wish.