Funky Dude
Funky Dude

Reputation: 3967

html entity encode text only, not html tag

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

Upvotes: 3

Views: 1908

Answers (2)

Scott Reed
Scott Reed

Reputation: 501

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.

Upvotes: 4

jwillmer
jwillmer

Reputation: 3790

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

Upvotes: 0

Related Questions