How to decode string to XML string in C#

后端 未结 7 1543
挽巷
挽巷 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:09

    You might also consider the static parse method from XDocument. I'm not sure how it compares to others mentioned here, but it seems to parse these strings well.

    Once you get the resulting XDocument, you could turn around with ToString to get the string back:

    string parsedString = XDocument.Parse("").ToString();
    

提交回复
热议问题