Remove all html tags except one tag

I have code to remove the entire html tag, but I want to remove all html except the </td> and </tr> tags.

How can I do that?

 public string HtmlStrip( string input) { input = Regex.Replace(input, "<input>(.|\n)*?</input>", "*"); input = Regex.Replace(input, @"<xml>(.|\n)*?</xml>", "*"); // remove all <xml></xml> tags and anything inbetween. return Regex.Replace(input, @"<(.|\n)*?>", "*"); // remove any tags but not there content "<p>bob<span> johnson</span></p>" becomes "bob johnson" } 
+4
source share
1 answer

Regex is not suitable for parsing XML or HTML. Take a look at HTML Flexibility Pack

HTML Agility Pack

+6
source

All Articles