Quick and Easy Method to Remove Html Tags

added by scwebgroup
4/9/2012 4:03:51 AM

0 Kicks, 156 Views

Here's a quick and dirty bit of C# code that will strip tags from an HTML document.


3 comments

dpeterson
4/9/2012 9:48:08 AM
This is an absolutely terrible way to strip html tags. Have you seriously not heard of string.Replace? Even a regex would be permissible, but this is asinine.

scwebgroup
4/9/2012 12:52:15 PM
My advice for you would be to actually read the article. You would learn two things: First, there is no possible way to do what my code does using String.Replace(). Second, I specifically mentioned regular expressions and why I wasn't using them. Hope this helps.

dpeterson
4/9/2012 12:57:32 PM
I re-read your article and realized I missed that you were replacing the entire tag with a space. The first time I read it I thought you were just replacing the angle brackets. Sorry about that.