The XmlSerializer.Serialize Method has overloads that accept TextWriter and XmlWriter.
My question is what are the practical differences between these two overloads in the follow examples? (list is a List<MyObjectModel>)
Example 1 (with TextWriter):
XmlSerializer serializer = new XmlSerializer(typeof(MyObjectModel));
using (TextWriter writer = new StreamWriter(savePath))
{
serializer.Serialize(writer, list);
}
Example 2 (with XmlWriter):
XmlSerializer serializer = new XmlSerializer(typeof(MyObjectModel));
using (XmlWriter writer = XmlWriter.Create(savePath))
{
serializer.Serialize(writer, list);
}
So far I've noticed that:
1) TextWriter seems to automatically perform indenting for you.
2) The default encoding for both is UTF-8.