Jatin kacha's Blog

Remove HTML Links from string

Posted on: September 16, 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

My tweets

%d bloggers like this: