Question: > 
> **Possible Duplicate:**  
> 
> [How to clean HTML tags using C#](https://stackoverflow.com/questions/1038431/how-to-clean-html-tags-using-c) 
> 
> 
> 

What is the best way to strip HTML tags in C#?

Answer: 
```
  public static string StripHTML(string htmlString)
  {

     string pattern = @"<(.|\n)*?>";

     return Regex.Replace(htmlString, pattern, string.Empty);
  }

```
Take your HTML string or document and parse it with [HTML Agility Pack](http://www.codeplex.com/htmlagilitypack). This will give you a HTMLDocument object that is very similar to a XmlDocument.

You can then use it's methods such as `SelectNodes` to access those portions of the document that you are interested in.

If you choose to use another approach, be aware that parsing HTML (a non-Regular language) with Regular Expressions is widely regarded as [a bad idea](http://www.codinghorror.com/blog/2009/11/parsing-html-the-cthulhu-way.html).

And regardless of the approach, if you are keeping some markup, use a whitelist approach. This means to remove everything that is not explicitly wanted.