I want to add at the top of my xml file some notes for the user who reads it. I am not sure how to do this though with xml serialization.
I was looking at this post<
Just put an XmlWriter as an intermediate level between the MemoryStream and the XmlSerializer:
static public MemoryStream SerializeToXML(MyWrapper list)
{
XmlSerializer serializer = new XmlSerializer(typeof(MyWrapper));
MemoryStream stream = new MemoryStream();
XmlWriter writer = XmlWriter.Create(stream);
writer.WriteStartDocument();
writer.WriteComment("Product XY Version 1.0.0.0");
serializer.Serialize(writer, course);
writer.WriteEndDocument();
writer.Flush();
return stream;
}
Your can add any XML before and after the serialized object graph (as long as the result is valid XML).