Im using the setting:
formatters.XmlFormatter.UseXmlSerializer = true;
The class i try to serailize is quite simple:
public class MyClass
{
public MyClass()
{
CDATA = "<![CDATA[<link>MyLink</link>]]>"
[XmlText]
public string CDATA { get; set; }
}
I want this to be serialized into something like:
<MyClass>
<![CDATA[<link>MyLink</link>]]>
</MyClass>
But instead get:
<MyClass>
<![CDATA[<!link>MyLink<!/link>]]>
</MyClass>
So how can i prevent this? Or is there a better way using the ASP.NET WebApi?
Looks like the answer from this question will do it:
This works with a regular
XmlSerializer
object, so I'd guess it works in WebAPI as well.