|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
XML Serialization of several objects over NetworkStreamI want to XML serialize several objects and send them over a NetworkStream. The serialization for a single objects works fine and the client can deserialize it without any problems but as soon as there is more than one object it fails on the second one, telling me that the root element is missing or wrong. In my opinion that's happening because XMLWriter doesn't insert a valid linbreak after the first objects. Here's the code of the serialization part: XmlSerializer xs = new XmlSerializer(maritimeObject.GetType()); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.ConformanceLevel = ConformanceLevel.Auto; settings.OmitXmlDeclaration = true; settings.CloseOutput = false; settings.Encoding = Encoding.UTF8; XmlWriter xmlWriter = XmlWriter.Create(stream, settings); xs.Serialize(xmlWriter, maritimeObject); xmlWriter.Close(); Deserialize is simply a call to the Deserialize method of an XmlSerializer. Here's a snippet of the Xml: </attributes> </MaritimeObject><?xml version="1.0" encoding="utf-8"?> <MaritimeObject> <mmsi>319307000</mmsi> <attributes> I would be really glad and thankful if somebody could help. Christoph |
|||||||||||||||||||||||