Converting HTML to Text using C# ASP.NET

Started by admin, August 28, 2008, 02:54:54 AM

Previous topic - Next topic

admin

Hello all,
did you think before how to convert HTML to Text and remove all HTML tags?
it is so easy using the Regular Expressions in the DOT NET, all you need is the following function :)
hoping to see your comments.




private string StripTags(string HTML)
        {
            // Removes tags from passed HTML           
            System.Text.RegularExpressions.Regex objRegEx = new System.Text.RegularExpressions.Regex("<[^>]*>");

            return objRegEx.Replace(HTML, "");
        }