c#strip html标签,解码实体

scz*_*vos 0 .net html c# winforms

PHP函数strip_tags和html_entity_decode是否有任何等价物?我正在使用.NET 3.5

所以,如果我有:

<textarea cols="5">Some &lt; text</textarea>
Run Code Online (Sandbox Code Playgroud)

我去拿

Some < text
Run Code Online (Sandbox Code Playgroud)

谢谢你的回应.

L.B*_*L.B 5

你可以使用HtmlAgilityPack ......

string html = @"<textarea cols=""5"">Some &lt; text</textarea>";
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);

var text = doc.DocumentNode.Descendants("textarea").First().InnerText;
var decodedText = HttpUtility.HtmlDecode(text);
Run Code Online (Sandbox Code Playgroud)