我有以下代码
foreach (HtmlNode link in htmldocObject.DocumentNode.SelectNodes("//a[@href]"))
{
HtmlAttribute attrib = link.Attributes["href"]; hTags.Add(att.Value);
}
这完全拉动了Href
,但我也想拉出href的描述
示例
<a href="/users/logout?returnurl=%2fquestions%2fask">log out</a>
所以我已经获得了/users/logout?returnurl=%2fquestions%2fask
但我还想获得log out
结果:
/users/logout?returnurl=%2fquestions%2fask | log out
答案 0 :(得分:4)
你想要的东西:
hTags.Add(att.Value + " | " + link.InnerText);