Kod:
c#
<option selected="selected" value="6">ANKARA</option>
değerindeki ANKARA yı değer olarak alamak için
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("option"));
{
if (el.GetAttribute("selected") == "True");
{
MessageBox.Show(el.InnerText);
}
}
yine de ilk yapıdaki gibi selected="selected" halini baz almak isterseniz, value=6'yi süzerek ANKARA'yı alabilirsiniz:
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("option"))
{
if (el.GetAttribute("value") == "6")
{
MessageBox.Show(el.InnerText);
}
}