我需要从我的webbrowser中获取所有属性.当前,我正在使用GetAttribute(),但这样,我需要知道属性的名称.
想象一下,我不知道我的webbrowser中有什么.
我的C#代码:
StringWriter strWriter = new StringWriter();
XmlWriter xWriter = XmlWriter.Create(strWriter, new XmlWriterSettings() { Indent = true });
xWriter.WriteStartElement("Items");
foreach (HtmlElement el in webBrowser1.Document.GetElementsByTagName("TEXTAREA"))
{
xWriter.WriteStartElement("Item");
xWriter.WriteElementString("GUID", el.Id);
xWriter.WriteElementString("Type", el.GetAttribute("type").ToUpper());
xWriter.WriteElementString("Name", el.Name);
xWriter.WriteElementString("Value", el.GetAttribute("value"));
xWriter.WriteElementString("MaxLength", el.GetAttribute("maxlength"));
xWriter.WriteEndElement();
}
我搜索了很多,但我没有找到任何有用的东西.