I have this old and dirty code I wrote some years ago that basically parsed css styles from local html documents. That code is really really ugly, and I would like to Qtify it!
I don't need rendering the webpage at all, just opening local files, reading them and closing them (in batch). How would you guys tackle this?
I first thought using the webkit somehing like:
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;
}
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;
}
To copy to clipboard, switch view to plain text mode
That didn't work... Why?
Can I work with html files like legal xml? In that case, getting the attributes from the styles is going to be somewhat annoying, knowing all the styles are declared in the "head"...
Any ideas, what Qclasses can be helpful here?
Bookmarks