private void savefile(object sender, RoutedEventArgs e)
{
List<Mark> markList = new List<Mark>();
markList.Add(new Mark("Physics",22));
markList.Add(new Mark("Chemistry", 23));
markList.Add(new Mark("Biology", 24));
markList.Add(new Mark("Maths", 25));
student s1 = new student();
s1.Name = "Bob";
s1.Class = "p1";
s1.MarkList =markList;
Serialise(s1);
}
static public void Serialise(student details)
{
XmlSerializer serializer = new XmlSerializer(typeof(student));
using (TextWriter writer = new StreamWriter(@"C:\Xml.xml"))
{
serializer.Serialize(writer, details);
}
}
On serializing , I am getting the output as follows.
<?xml version="1.0" encoding="utf-8"?>
<student xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>Bob</Name>
<Class>p1</Class>
<MarkList>
<Mark />
<Mark />
<Mark />
<Mark />
</MarkList>
</student>
The Mark tags are not populating the data.
Please help..
Thanks in advance.