Saturday, April 11, 2009

Strip HTML tags from string

This code sample removes all the HTML tags (any text between < >) within the given text. YOu can use thsi function to stripp off all HTML tags from a web page and display as plain text. This sample code will replace only words enclosed within < >. If there is < or > with no text in between, they will not be removed.


Dim objRegExp as New RegEx("<(.|\n)+?>")
string plainText = objRegExp.Replace(htmlText, "")

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home