Reputation: 1841
I am trying to read HTML source using webbrowser control in C#.
The HTML source contains the following line:
input class="myclass" name="commit" type="submit" value="Submit"
I am trying to read the above by using following code:
HtmlElementCollection buttonElement = webBrowser1.Document.GetElementsByTagName("commit");
But it doesn't return any element. I printed buttonElement.Count value and it prints 0.
When I right click in webbrowser control and view source then I can see this element "commit" is there and there is no other element by this name.
Upvotes: 0
Views: 4858
Reputation: 116098
It's tag name is input
. Therefore your code should be something like this
var element = webBrowser.Document.GetElementsByTagName("input")
.Cast<HtmlElement>()
.Where(e => !String.IsNullOrEmpty(e.GetAttribute("name")) && e.GetAttribute("name") == "commit")
.FirstOrDefault();
Upvotes: 2