Get plain text from HTML in .NET

后端 未结 5 1744
清酒与你
清酒与你 2020-12-30 21:34

What is the best way to get a plain text string from an HTML string?

public string GetPlainText(string htmlString)
{
    // any .NET built in utility?
}
         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-30 22:05

    There isn't .NET built in method to do it. But, like pointed by @rudi_visser, it can be done with Regular Expressions.

    If you need to remove more than just the tags (i.e., turn â to â), you can use a more elaborated solution, like found here.

提交回复
热议问题