Sunday, March 11, 2012

How to remove HTML tag

 

Below code remove the HTML tag. It removes HTML tag from your string.

public string RemoveHtmlTag(string html, bool allowHarmlessTags)

{

if (html == null || html == string.Empty)

return string.Empty;

 

if (allowHarmlessTags)

return System.Text.RegularExpressions.Regex.Replace(html, "", string.Empty);

 

return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty);

//return html;

}

 

public string RemoveHtmlTagSearch(string html)

{

if (html == null || html == string.Empty)

return string.Empty;

 

return System.Text.RegularExpressions.Regex.Replace(html, "<[^>]*>", string.Empty);

 

}

1 comment:

  1. Hey nice story... I love the way you presented whole story, Thanks for sharing such a useful information with us software training institutes | Summer training in embedded

    ReplyDelete

Note: Only a member of this blog may post a comment.