Bronzato
Bronzato

Reputation: 9362

Decode html tags into a string

I have an attribute in my model which contains html string like below:

<p>Solution web de contr&ocirc;le financier &agrave; chacune des &eacute;tapes du cycle de soumission et de validation des d&eacute;penses. La gestion fortement param&eacute;trable des workflows favorise son int& eacute;gration avec des applications tierces (pgm de gestion des d&eacute;penses) et son d& eacute;ploiement dans une organisation d&eacute;centralis&eacute;e.< /p>

As you can see we have some html chacacters like <p> &oirc; ...

I would like to be able to get this string with all special characters decoded. How can I do?

So this line: <p>Solution web de contr&ocirc;le</p>

Should give me: Solution web de contrôle

Upvotes: 0

Views: 1391

Answers (2)

Oded
Oded

Reputation: 499392

Use HttpUtility.HtmlDecode:

string decoded = HttpUtility.HtlmDecode("<p>Solution web de contr&ocirc;le</p>");

This will take care of the character entities (&ocirc;), but you will still need to strip out the HTML tags.

Upvotes: 0

m.edmondson
m.edmondson

Reputation: 30922

HttpUtility.HTMLDecode will do what you need.

Upvotes: 1

Related Questions