How to decode string to XML string in C#

后端 未结 7 1545
挽巷
挽巷 2020-11-27 20:41

I have a string (from a CDATA element) that contains description of XML. I need to decode this string into a new string that displays the characters correctly using C#

7条回答
  •  春和景丽
    2020-11-27 21:29

    You just need to replace the scaped characters with their originals.

    string stringWanted= existingString.Replace("<", "<")
                                                       .Replace("&", "&")
                                                       .Replace(">", ">")
                                                       .Replace(""", "\"")
                                                       .Replace("'", "'");
    

提交回复
热议问题