leo*_*ora 3 html c# asp.net-mvc
我想从数据库中查询字符串(html)并将其显示在网页上.问题是数据有一个
<p> around the text (ending with </p>
Run Code Online (Sandbox Code Playgroud)
我想在我的viewmodel或controlleraction中删除返回此数据的外部标记.在C#中执行此操作的最佳方法是什么?
可能会因你的需要而过度杀戮,但是如果你想解析HTML,你可以使用HtmlAgilityPack - 一般来说这是一个比大多数建议更清晰的解决方案,尽管它可能不是那么高效:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml("<p> around the text (ending with </p>");
string result = doc.DocumentNode.FirstChild.InnerHtml;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6340 次 |
| 最近记录: |