Link so...">

Using HtmlAgilityPack to Change Hyperlink Tags

How to use HtmlAgilityPack to replace all hyperlinks, for example:

<a href="url">Link</>

so that only the href attribute remains. url

Is it possible?

+3
source share
1 answer
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
+5
source

Source: https://habr.com/ru/post/1710326/


All Articles