khtml library tutorials/guides?

330 Views Asked by At

I'm trying to use the khtml library, basically just the DOM html implementation from there, but I even failed to create a basic HTMLDocument from a file using load(), and when I tried to create a HTMLDOcument by mutating it via appendChild I get DOMException with errorcode == 8 (NOT FOUND).

Can anyone please point me to some sample code which uses khtml's dom model without obtaining the document from the GUI components?

2

There are 2 best solutions below

0
A. Novikov On

Ok, I see what the problem was.

First, if you're using a local html file, your uri needs to be absolute when you call DOM::HTMLDocumemt::load(const DOM::DOMString&).

Secondly, you need to create a DOM document, but it's read-only by default after creation. So, before you actually call load(), you need to make it editable via

DOM::Document::setDesignMode(bool designOn).

That fixes it.

2
OneOfOne On

If I may recommend, WebKit is far superior to khtml now, even konqueror will be using webkit by default next release.

Check QtWebkit.