views:

53

answers:

2

Hi!

I'm writing a Browser Helper Object (BHO) for Internet Explorer in C#!

I want to look for text nodes in the DOM, which requires me to traverse the whole DOM tree if I want to differentiate between text nodes and other types of nodes. This is supposedly time consuming in C#, but should be almost instantanious in C++ (?).

Is there a way to do the traversing in c++ instead? A dll that I can call from C# perhaps, using DllImport? Is it easy to pass the HTMLDocument to my externally exposed c++-method?

Any other ideas?

Cheers!

+1  A: 

Where did you get the "supposedly" from? Most of the time will be spent in the code that implements the DOM. Which was written in C++ by Microsoft.

Marshal.GetIUnknownForObject() gets you a raw interface pointer that you can pass to native code. It needs to QI that pointer for IHtmlDocument2 and take it from there.

Hans Passant
A: 
This is supposedly time consuming in C#,

This is just wrong.

Most of the user's time will be spent waiting for the HTML to arrive at the browser, and for the browser to draw it on the screen. Compared to that, walking the DOM (in any language) is a snap.

egrunin