且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在HTML中编码特殊字符但排除标签

更新时间:2022-11-22 11:58:44

如上面的MatthewG所述,答案已经发布到

As noted by MatthewG above, the answer had already been posted to html entity encode text only, not html tag - the solution is to use HTMLAgilityPack and pass the html text or node to the method entitize - this encodes only the page content and not the tags.

using HtmlAgilityPack;
html = HtmlEntity.Entitize(html);