Using Qt to read and parse html files with QWebKit?
- by Alberto Toglia
I would like to read and parse certain elements of html files but I'm not interested in rendering it in any way.
Basically I would like to go through all my div tags and get some of its style attributes.
This is what I've done so far:
QWebPage page;
QWebFrame * frame = page.mainFrame();
QUrl fileUrl("localFile.html");
frame->setUrl(fileUrl);
QWebElement document = frame->documentElement();
QWebElementCollection elements = document.findAll("div");
foreach (QWebElement element, elements){
std::cout << element.attribute("style").toStdString() << std::endl;
}
Doesn't show anything.
I'm somewhat confused if I could use webkits this way.
P.D.: I'm using a filechooser to pick the local html root.