How to serialize a model, so I can use the standard methods of NET?
In normal serialization:
//model as MainModel var xmlSerializer = SerializationFactory.GetXmlSerializer(); xmlSerializer.OptimalizationMode = XmlSerializerOptimalizationMode.PrettyXmlAgressive; Stream stream = new MemoryStream(); xmlSerializer.Serialize(model, stream); string text = Encoding.UTF8.GetString((stream as MemoryStream).ToArray()); I get:
<?xml version="1.0" encoding="utf-8"?> <MainModel graphid="1" xmlns:ctl="http://catel.codeplex.com"> ... And then I try to:
XmlDocument xmlDocument = new XmlDocument(); xmlDocument.PreserveWhitespace = true; xmlDocument.LoadXml(MySerializedToXMLModel); I got error in LoadXML.
No comments:
Post a Comment