c# - Return all attributes of an HtmlElement in Web browser -
i need of attributes webbrowser.currently,i using getattribute() way,i need know name of attributes. imagine not know in webbrowser. c# code:
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(); }
i have searched lot did not find thing useful.
i haven't tried it, guess solution or first step. first, have reference microsoft.mshtml
foreach (htmlelement el in webbrowser1.document.getelementsbytagname("textarea")) { htmltextareaelement textarea = (htmltextareaelement)el.domelement; xwriter.writestartelement("item"); xwriter.writeelementstring("guid", el.id); foreach (var attribute in textarea.attributes) { string name = attribute.name; string value = attribute.value; xwriter.writeelementstring(name, value); } xwriter.writeendelement(); }
Comments
Post a Comment