如何使用HtmlAgilityPack替换所有超链接,例如:
<a href="url">Link</>
这样只剩下href属性。网址。
这可能吗?
答案 0 :(得分:5)
Dim Doc as HtmlDocument = new HtmlDocument
doc.LoadHtml(MyHtml)
Dim links As HtmlNodeCollection = doc.DocumentNode.SelectNodes("//a")
For Each link In links
Dim att As HtmlAttribute = link.Attributes("href")
MyHtml = Myhtml.Replace(link.OuterHtml, att.Value)
Next