WikiCrawler/Utility/StringUtility.cs
/// <summary>
/// Removes HTML tags from the specified string.
/// </summary>
Removes HTML tags from the specified string.
Removes HTML tags from the specified string .
public static string CleanHtml(string text)
	{
		int startIndex = -1;
		for (int c = text.Length - 1; c >= 0; c--)
		{
			if (startIndex < 0)
			{
				if (text[c] == '>')
				{
					startIndex = c;
				}
			}
			else
			{
				if (text[c] == '<')
				{
					string tagContent = text.Substring(c + 1, startIndex - c - 1);
					if (!tagContent.Trim().StartsWith("br"))
					{
						text = text.Remove(c, startIndex - c + 1);
					}
					startIndex = -1;
				}
			}
		}
		text = WebUtility.HtmlDecode(text);
		text = text.Trim();
		return text;
	}
public static string CleanHtml ( string text ) { int startIndex = - 1 ; for ( int c = text . Length - 1 ; c >= 0 ; c -- ) { if ( startIndex < 0 ) { if ( text [ c ] == ' ' ) { startIndex = c ; } } else { if ( text [ c ] == ' ' ) { string tagContent = text . Substring ( c + 1 , startIndex - c - 1 ) ; if ( ! tagContent . Trim ( ) . StartsWith ( " " ) ) { text = text . Remove ( c , startIndex - c + 1 ) ; } startIndex = - 1 ; } } } text = WebUtility . HtmlDecode ( text ) ; text = text . Trim ( ) ; return text ; }
Removes HTML tags from the specified string.
Removes HTML tags from the specified string .
//TODO trim brs
text
string