Author Topic: Converting HTML to Text using C# ASP.NET  (Read 6459 times)

Offline admin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 296
    • View Profile
Converting HTML to Text using C# ASP.NET
« on: August 28, 2008, 08:54:54 AM »
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.


Code: [Select]

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

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