Modifying hyperlink tags using HtmlAgilityPack

html-agility-pack

Question

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
3
12/23/2009 2:36:07 PM

Popular 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
6/12/2009 10:49:41 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow