I am trying to deserialize a Xml File using the XmlSerializer. A part of my file looks like this:
<bla>
<ListOfListOfTest>
<ListOfTest>
<Test>
</Test>
</ListOfTest>
</ListOfListOfTest>
</bla>
I tried different ways but it does not work.
My first try looked like:
public class bla
{
public bla()
{
ListOfListOfTest = new List<List<Test>>();
}
[...]
public List<List<Test>> ListOfListOfTest{ get; set; }
}
-> does not work.
Second try:
public class bla
{
public bla()
{
ListOfListOfTest = new List<List<Test>>();
}
[..]
public List<List<Test>> ListOfListOfTest { get; set; }
[XmlArrayItemAttribute]
public List<List<Test>> listOfListOfTest { get { return ListOfListOfTest ; } }
}
-> failed as well
Third try:
public class bla
{
public bla()
{
ListOfListOfTest = new List<Foo>();
}
[...]
public List<Foo> ListOfListOfTest { get; set; }
}
public class Foo
{
public Foo()
{
ListOfTest = new List<Test>();
}
public List<Test> ListOfTest { get; set; }
}
-> failed...
Failed means that the XmlSerializer does not fill the List during serializer.Deserialize().
I´m always getting a List with zero Elements in it.
What am i doing wrong?
thanks for your effort
XmlElement,XmlArrayandXmlArrayItemattributes. The XmlSerializer apparently needs some meta info to understand what belongs where.Test?