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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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.
Method 2
if you need a bunch of functions use the htmlagilitypack. if you just need urls or something in specific tags a selfwritten parser would be more efficient
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0