c# webbrowser 获取已选择元素中的别的属性?

c# webbrowser 获取已选择元素中的别的属性


狐的传说
浏览 1805回答 4
4回答

犯罪嫌疑人X

我没用过,但是我觉得如果这个类库的作者靠谱的话,那么你的Element应该会有Attributes这样的属性,代码可能为:(假设我有一个)var element= webBrowser1.Document.GetElementById("some id");var attribute = element.Arributes["some attribute name"];或者var attribute = element.GetArributeByName("some attribute name");

慕莱坞森

由于class是JavaScript的保留关键字,所以在ie中用className代替classforeach (HtmlElement he in web_bs.Document.GetElementsByTagName(“DIV“)){rtb_html.Text = he.GetAttribute(“className“);if (rtb_html.Text==“aainText“){rtb_txt.Text = he.InnerHtml;}}

慕村225694

方法1实现枚举WebBrowser.document下的HtmlElement.TagName属性,如果该属性="DIV",获取这个HtmlElement.的innerHtml,对结果字符串判断是否包含class="aainText",是的话,这个HtmlElement.的innerText就是你的目的文本了方法2对整个WebBrowser.document.body.innerHtml用正则式匹配来取值

慕无忌1623718

这个是要进行元素的属性获取wb.Document.GetElementById("QuickLogin").GetAttribute("display").ToString();
打开App,查看更多内容
随时随地看视频慕课网APP