I have this class:
[XmlRoot(ElementName ="Lesson")]
public class LessonOld
{
public LessonOld()
{
Students = new List<string>();
}
public string Name { get; set; }
public DateTime FirstLessonDate { get; set; }
public int DurationInMinutes { get; set; }
public List<string> Students { get; set; }
}
And I'm using this code to serialize it:
TextWriter writer = new StreamWriter(Path.Combine(UserSettings, "Lessons-temp.xml"));
XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<LessonOld>));
xmlSerializer.Serialize(writer, tempList);
writer.Close();
(Note that that is a List<LessonOld>
)
Here is my resulting XML:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfLessonOld xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<LessonOld>
<FirstLessonDate>0001-01-01T00:00:00</FirstLessonDate>
<DurationInMinutes>0</DurationInMinutes>
<Students />
</LessonOld>
</ArrayOfLessonOld>
I would like to change it to serialize as <ArrayOfLesson
and <Lesson>
for the XML elements. Is this possible? (As you can see, I've already tried using [XmlRoot(ElementName ="Lesson")]
)