Given the following html in a Winforms Webbrowser DOM, I'm attempting to get the second element with value="type102"
<div class="Input"><input type="radio" name="type" value="type101"
onclick="setType('type101');"><a href="javaScript:setType('type101');"
onclick="s_objectID="javascript:setType('type101');_1";return this.s_oc?
this.s_oc(e):true">type101</a></div>
<div class="Input"><input type="radio" name="type" value="type102"
onclick="setType('type102');" checked="checked"><a href="javaScript:setType('type102');"
onclick="s_objectID="javascript:setType('type102');_1";return this.s_oc?
this.s_oc(e):true">type102</a></div>
I've used
HtmlElement htmlElem = browser.Document.GetElementById(....
and
HtmlElement htmlElem = browser.Document.All.GetElementsByName(....
before, but in this instance they are both the same so would need to get by value or href
Is it possible to get the second element directly without external libraries or would I have to get a collection of GetElementsByName and iterate through them?
HtmlElementCollection col= webBrowser1.Document.GetElementsByTagName("input");
HtmlElement wanted;
foreach (HtmlElement item in col)
{
if (item.GetAttribute("value")=="type102")
{
wanted = item;
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With