Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html entity encode text only, not html tag

Tags:

c#

asp.net

i have a string that contains a bunch of html. i want to html-encode the text within the html tags but not the tags themselves. is there an easy way to do this in asp.net c# 3.5

like image 694
Funky Dude Avatar asked Aug 08 '26 20:08

Funky Dude


1 Answers

You could use the HTML Agility Pack (available via nuget) to read the HTML then if necessary use the HtmlEncode method to encode the specific values by querying them.

like image 129
Scott Reed Avatar answered Aug 11 '26 09:08

Scott Reed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!