Reputation: 1453
I have a class that I am serializing using System.Xaml.XamlObjectReader
and the System.Xaml.XamlXmlWriter
. Everything goes good on everything until I get to my property that contains an XDocument
. I get Unable to serialize type 'System.Xml.Linq.XDeclaration'.
How can I during my while loop to serialize the object nodes to disk get it to write out the xml in this property?
Upvotes: 3
Views: 1179
Reputation: 2554
You can convert this to CData and serialize it. You can refer this example for details How do you serialize a string as CDATA using XmlSerializer?
Or you can also escape xml tags of ToString() of XDocument. e.g. String escape into XML
Upvotes: 1