Convert HTML codes to plain text

15,298

Solution 1

System.Web.HttpUtility.HtmlDecode("Col´gio");

Solution 2

Just for completion:

If you are using .NET 4.0+ you can also use WebUtility.HtmlDecode

Solution 3

SecurityElement securityElement = System.Security.SecurityElement.FromString("<test>H&amp;M</test>");
string unescapedText = securityElement.Text;
Console.WriteLine(unescapedText); // Result: H&M
Share:
15,298
Bruno Cruz
Author by

Bruno Cruz

Updated on June 16, 2022

Comments

  • Bruno Cruz
    Bruno Cruz almost 2 years

    I've a string for example like this:

    Col&acute;gio
    

    How can I convert it to:

    Colégio
    

    Without having to do a replace for all the html codes