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!");
}