Add in Express for IE, Interrogating DOM

Add-in Express™ Support Service
That's what is more important than anything else

Add in Express for IE, Interrogating DOM
Can someone give a one line example of how to search DOM (VB .NET) 
Chris King




Posts: 9
Joined: 2008-07-22
Hi, I'm writing an IE toolbar application and I need to extract some values that will be displayed on a web page.
I have been able to search the html of the page by looking at the example code, but I want to get some settings that only appear in the DOM.

Can anyone give me a simple example of how you would search the DOM for an INPUT with Id and return it's value?
Posted 17 Sep, 2008 04:18:13 Top
Eugene Astafiev


Guest


Posted 17 Sep, 2008 06:30:58 Top
Chris King




Posts: 9
Joined: 2008-07-22
I have, but this only seems to deal with the HTML content, not the DOM.
Posted 22 Sep, 2008 04:38:54 Top
Eugene Astafiev


Guest


Hi Chris,

Did you try to use the following code?

mshtml.IHTMLElement element = HTMLDocument.getElementById("id");
string text = element.innerText;
if(element!=null)Marshal.ReleaseComObject(element);
Posted 22 Sep, 2008 06:48:04 Top
Chris King




Posts: 9
Joined: 2008-07-22
Do you know how this should look in VB .NET?
Posted 22 Sep, 2008 11:02:41 Top
Eugene Astafiev


Guest


Hi Chris,

Here is the code in VB.NET:

Dim element As mshtml.IHTMLElement = HTMLDocument.getElementById("id")
Dim text As String = element.innerText
If (element IsNot Nothing) Then Marshal.ReleaseComObject(element)
Posted 22 Sep, 2008 11:28:37 Top
Chris King




Posts: 9
Joined: 2008-07-22
Thats how I thought it should look, but I get:
'Reference to a non-shared member requires an object reference' on
Dim element As mshtml.IHTMLElement = HTMLDocument.getElementById("id60")
Posted 23 Sep, 2008 04:22:01 Top
Eugene Astafiev


Guest


Hi Chris,

Could you provide us with the code in which you use the getElementById function?
Posted 23 Sep, 2008 08:23:44 Top
Eugene Astafiev


Guest


Chris,

Try to use the following code instead:

Dim element As mshtml.IHTMLElement = Me.HTMLDocument.getElementById("id60") 


Does it help?
Posted 23 Sep, 2008 08:33:53 Top