简体   繁体   中英

Serialize Property that contains XDocument

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?

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. eg String escape into XML

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM