Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using HtmlAgilityPack to modify hyperlink tags

How to use HtmlAgilityPack to Replace all hyperlinks, e.g.:

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

so that only the href attribute is left. the url.

Is this possible?


1 Answers

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

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!