如何在不删除 html 标签的情况下将 html 转换为文本

How to convert html to text without removing html tags

convert this into this]2 我正在尝试使用 html 标签(p,ol,b)[! 转换为普通文本(如 运行 代码片段的结果)——我尝试在 .net core 中使用以下代码,但结果是 html 没有格式化(例如:p 标签应显示段落,< ol 应转换为数字,

 var doc = new HtmlDocument();
            doc.LoadHtml(sampleHtml);
            var innertext = doc.DocumentNode.InnerText;

也尝试使用 HTMLAgility 包,但没有成功。

Html.Raw(sampleHtml) works with mvc razor but not with .net core.

<p>Angular is a platform for building mobile and desktop web applications. It has a big community of millions of developers who choose Angular to build compelling user interfaces.:</p><ol><li>Angular is a JavaScript open-source front-end web application framework..</li><li>Angular solves many of the challenges faced when developing single page, cross platform, performant applications.</li></ol><p><b>Angular</b/></p><p><b>What's new</b/></p><p><b>Angular is a complete rewrite of AngularJS.</b/></p><p>Angular does not have a "scope" concept or controllers, instead, it uses a component hierarchy as its main architecture.</p><p><b>Warning</b/></p><p>Static Typing (<b>support</b>) for the purpose of study. 

请评论您的想法和实现方法。谢谢

感谢您的所有回复。我能够在 angular 模板中完成它,而不是使用 <p [innerHTML]="sampleHtml">'. innerHTML></p> 从 C# 获取转换后的 html,innerHTML 不适用于我试图做的 'textarea',所以我用了一段,div也可以用