views:

211

answers:

1

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?

A: 
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