Why does HtmlElement's GetAttribute() method return "mshtml.HTMLInputElementClass" instead of the attribute's value?
Why does HtmlElement
's GetAttribute()
method return mshtml.HTMLInputElementClass
instead of the attribute's value, when I'm trying to obtain the value of a form's action
attr开发者_如何学运维ibute?
HtmlElementCollection elements = webBrowser1.Document.Forms;
foreach (HtmlElement element in elements)
MessageBox.Show(element.GetAttribute("action") + "");
It seems to be an IE bug.
Here is a solution : add a reference to Microsoft.mshtml, then :
if(element.GetAttribute("action").Equals("mshtml.HTMLInputElementClass"))
{
mshtml.IHTMLFormElement iForm = (mshtml.IHTMLFormElement)element.DomElement;
string action = iForm.action;
}
Hope this help :)
精彩评论