Jatin kacha's Blog

Archive for September 2011

You can use following function to remove HTML links or say HTML anchor tags from a string.

Well its not my own algorithm to do so. I referred following HTML parser to do this. You can download it from here.

It is a an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT.

Here is the function for your assistance.


Function WrapOutAll_A_Tag_From_HTML(ByVal description As String) As String

Dim doc As New HtmlAgilityPack.HtmlDocument()
Dim stream As New System.IO.StringReader(description)

Dim _return As String = “”

Dim all_A As New System.Collections.Generic.List(Of String)
Dim node As HtmlAgilityPack.HtmlNode

For Each node In doc.DocumentNode.Descendants(“a”)

Dim s As String
For Each s In all_A.ToArray()
If Not doc.DocumentNode.SelectSingleNode(s) Is Nothing Then
End If

_return = doc.DocumentNode.InnerHtml()
Catch ex As Exception
_return = description
End Try

Return _return
End Function

Using this function, you can remove HTML links/HTML anchor tags from your string content.

My tweets