QML and querySelector
-
Hi,
i'm a beginner with QML (and Qt in general). I use Qt quick to create a Qt mobile app, and i want to load content from my website. I don't want to provide a web service from my web site so i thought i could use querySelector. But i don't succeed because querySelector is a method provided by window.document
The query to the webpage is done by a javascript using XmlHttpRequest :
@
function parsePage(htmlContent) {
// document.querySelector('#list');
}// function use as callback for doWebRequest
function updateText(data) {
textAreaHomePage.html = parsePage(data); // textAreaHomePage is a webView resources
}function doWebRequest(method, url, callback) {
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
var status = doc.status;
if(status!=200) {
showError("Google API returned " + status + " " + doc.statusText);
}
} else if (doc.readyState == XMLHttpRequest.DONE) {
var data;
var contentType = doc.getResponseHeader("Content-Type");
data = doc.responseText;
callback(data);
}
}doc.open('GET', url, true); doc.send();
}
@I wished to use css selector because it's independant from correct HTML content. I thought that if i inject Html into WebView, this component will then act like a page with document dom element. But i 'm wrong. Maybe there is other way of doing what i want. So is there a way to parse easily htmlContent returned by XmlHttpRequest ? i cannot use xml parsing because CMS doesn't provide always correct HTML.
Thanks for help
Dev env : win7, Qt 4.8, compile for Symbian