C# 为什么HtmlElement';s GetAttribute()方法返回;mshtml.HTMLInputElementClass“;而不是属性';s值多少?

C# 为什么HtmlElement';s GetAttribute()方法返回;mshtml.HTMLInputElementClass“;而不是属性';s值多少?,c#,browser,C#,Browser,当我试图获取表单的操作属性的值时,为什么HtmlElement的GetAttribute()方法返回mshtml.HTMLInputElementClass而不是属性的值 HtmlElementCollection elements = webBrowser1.Document.Forms; foreach (HtmlElement element in elements) MessageBox.Show(element.GetAttribute("action") + "

当我试图获取表单的
操作
属性的值时,为什么
HtmlElement
GetAttribute()
方法返回
mshtml.HTMLInputElementClass
而不是属性的值

HtmlElementCollection elements = webBrowser1.Document.Forms;
   foreach (HtmlElement element in elements)
        MessageBox.Show(element.GetAttribute("action") + "");

这似乎是一个IE错误

下面是一个解决方案:添加对Microsoft.mshtml的引用,然后:

if(element.GetAttribute("action").Equals("mshtml.HTMLInputElementClass"))
{
    mshtml.IHTMLFormElement iForm = (mshtml.IHTMLFormElement)element.DomElement; 
    string action = iForm.action;
}

希望这有帮助:)

无需重复。发布显示表单的HTML。有效示例:表单的操作似乎会导致https页面。这应该是原因吗?