Reputation: 3447
I have a string with CData encoded value in it. How can I decode this properly. Using XElement.Parse() throws an error because there is no root element.
var rawXml = GetFromExternalService();
var myValue = XElement.Parse(rawXml).Element("Description").Value;
The variable myValue is now <![CDATA[some interesting stuff \r\n]]>
. So in fact this is an error from the service, double encoding the value. But I can't change that.
I could just strip the first 9 and the last 3 characters, but that just feels so wrong.
What is the best way to get the real value?
Kind regards
Damiaan
Upvotes: 0
Views: 257