views:

1536

answers:

3
+3  Q: 

WebKit API for DOM

Does WebKit expose an API for working directly with its DOM? I'm looking for a class like HtmlElement that can be used to build/traverse trees of HTML content.

I'm trying to host WebKit as a web browser control in a desktop application, and would prefer a direct API rather than going through COM. Thanks!

Thanks!

+2  A: 

Following URL has some interesting answer to you.

Where is WebKIT API?

lakshmanaraj
Thanks ... I wonder how Google incorporated WebKit into Chrome??
Jen
by taking the source code and compiling it, of course - how else? sorry, but this is a silly question, jen :)
+1  A: 

Using QT/WebKit (at least version 4.6) it's now possible to access the DOM of the loaded document.

QtWebKit Module reference

Luca Tettamanti
the PyWebkitQt DOM accessor API is utterly shit beyond belief. in order to get python callbacks for event handling, you have to - unbelievably - create a javascript code-snippet which references the python function as the callback. then, if you want to create an element, to be added to the DOM, you again have to execute a javascript code snippet, add a fake "id" to it, call getElementsById using the botched Qt DOM accessor function and then create a wrapper API to "nanny" that object. it's just utterly shit.
A: 

you have a limited number of options, via the various DOM wrappers. the PyWebkitQt one is truly rubbish; the Objective-C one is only available on MacOSX (and is again limited and incomplete); the COM one is only available on windows; the GObject one is still under development even though the first version that was created in 2008 was superior and more feature-complete than what's actually now in webkit mainline source code; there are also some c++ bindings but i have not evaluated them. and then of course there's also the Javascript bindings and the google V8 javascript bindings (yes they're separate) but those are only available "in-browser".

that pretty much leaves the pythonwebkit project - http://www.gnu.org/software/pythonwebkit - as the only non-javascript-based DOM manipulation API that actually aims for full de-facto standards compliance, making python truly a peer of javascript when it comes to DOM manipulation.

l.