user2184881
user2184881

Reputation: 41

Loop over every Htmlelement on a page in a WebBrowser control

I am trying to make a loop to find every HtmlElement from the webpage which, I am currently on in my web browser control in C#.

I've tried:

var elements = webbrowser1.Document.GetElementsByTagName("textarea");

foreach (HtmlElement el in elements) {
    MessageBox.Show(el);
}

Upvotes: 2

Views: 10618

Answers (1)

Jesse
Jesse

Reputation: 8759

I'll post this as an answer, so that it's easy to find.

All document elements are under webBrowser1.Document.All.

You can iterate over them as such:

foreach (HtmlElement element in webBrowser1.Document.All)
{
    MessageBox.Show(element.Id);
}

Upvotes: 8

Related Questions