Logo
My Account |  Site Map | Contact Us  
Welcome Guest Search | Active Topics | Sign In | Register

Hello, can you give me an example of using EO.WebBrowser.DOM.Collection Options
sexfio
Posted: Tuesday, May 19, 2020 1:30:43 AM
Rank: Newbie
Groups: Member

Joined: 3/21/2020
Posts: 5
Hello, can you give me an example of using EO.WebBrowser.DOM.Collection ??
thx
eo_support
Posted: Tuesday, May 19, 2020 12:27:29 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 22,187
Hi,

Here is some sample code:

Code: C#
//EvalScript returns a JavaScript array
object obj = webView.EvalScript("document.getElementsByTagName('a');");

//Cast to strong typed Collection<Element>
var col = JSObject.CastTo<EO.WebBrowser.DOM.Collection<EO.WebBrowser.DOM.Element>>(obj);

//Look through all Element
int n = col.length;
for (int i = 0; i < n; i++)
{
    var item = col[i];
    System.Diagnostics.Debug.WriteLine(item.innerHTML);
}


Please keep in mind that such code are strongly discouraged for performance reason. See here for more details:

https://www.essentialobjects.com/doc/webbrowser/advanced/jsdom.aspx

The class exists as a fast convenience way because its nor ".NET like" and might be easier to use with certain .NET features (for example, WPF data binding) but it is very inefficient. So you should not use such code in production.

Thanks!
sexfio
Posted: Tuesday, May 19, 2020 1:44:50 PM
Rank: Newbie
Groups: Member

Joined: 3/21/2020
Posts: 5
I see,thank you for your reply :)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.