如何删除html标签,只留下C#中的文字?

时间:2013-03-09 06:10:55

标签: c# asp.net html

我看到一个类似的案例以JQuery方式回答我的问题: Remove tag but leave contents - jQuery/Javascript

但我需要知道C#是如何为此工作的? C#中是否有任何API可用于删除标记并保留平面文本?

自:

<a href="#">some content</a> and more <a href="#"> and more content</a>

要:

some content and more and more content

感谢。

1 个答案:

答案 0 :(得分:0)

使用HtmlAgilityPack(http://htmlagilitypack.codeplex.com/),将HTML文档加载到HtmlDocument实例中并查询document.DocumentNode.InnerText

相关问题