0
使用此示例如何使用C#HTMLElement的Get Attribute获得此行上的“GOOGLE CLICK”。假设这个元素被getElementByTagName吸收了。我不知道该用什么样的属性我已经试过“HTML” &“文本”(得element.GetAttribute(“HTML”)),这是工作于Java,但遗憾的是没有属性C#。HTMLElement的GetAttribute(“html”)或GetAttribute(“text”)不返回值
<a href="www.google.com">GOOGLE CLICK</a>
供参考这里是我的c#示例代码,我试图运行。
//web is the current page i am at.
HtmlElementCollection links = web.Document.GetElementsByTagName("a");
foreach (HtmlElement link in links)
{
if (link.GetAttribute("text") == "GoogleClick")
MessageBox.Show(this, "Hooray I got it!");
}