Skip to content Skip to sidebar Skip to footer

How To Encode Special Characters In Html But Exclude Tags

I'm trying to convert an HTML page into one containing proper named entities, converting quotes, double quotes to entities. I tried the following code which works but encodes the H

Solution 1:

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);

Post a Comment for "How To Encode Special Characters In Html But Exclude Tags"