views:

512

answers:

3

I am writing a server application that is able to manipulate the DOM before it is served to the client.
I am using C++ and Google's v8 as a javascript engine but I don't see any DOM API in v8.
Is there an open source implementation for doing DOM manipulation on HTML?
If not how would you implement one?

+1  A: 

Safari/Chrome use the Webkit rendering engine, which incorporates CSS rendering and the DOM, I would say it's one of the best rendering engines in addition to Opera's - I think it could be of use:

http://webkit.org/

meder
the_drow
+1  A: 

The DOM is created and linked to the V8 engine in Chrome. The V8 sources know nothing about the browser DOM. The quickest way to get this working for you would be to try to extract the parts of Chrome (Chromium, really) that load HTML into a structure, and the parts that link the DOM and DOM methods into V8. It's probably not as bad as you think. If anything, Google produces pretty clean C++, as far as I can tell from looking at the V8 source code. It's probably not as bad as you think.

postfuturist
+1  A: 

Have you checked out CplusplusDOM? (which has been created after your question was asked)

The C++ DOM API is a library for writing Web applications in C++ over NPAPI/Pepper using the Web IDL C++ binding for accessing DOM objects inside the Web browser.

Motti