Stripping HTML tags
Another solution from Gyurisc. Maybe I should open a competition ;-)
here is my quick and dirty solution, although with regular expressions is more elegant, I guess I need to buy a RegExp book :)))
public static string StripHTMLTags(string html)
{
string[] open_fragments = html.Split(new Char[] {'<'});
StringBuilder sb = new StringBuilder();
foreach(string fragment in open_fragments)
{
int loc = fragment.IndexOf('>');
// the very last char is the closing tag
if(fragment.Length-1 == loc)
continue;
if(loc>0)
sb.Append(fragment.Substring(loc+1));
else
sb.Append(fragment);
}
return sb.ToString();
}