Xml is here
<?xml version="1.0" encoding="utf-8"?>
<s>
<Items>
<b name="test" width="100">
<Items>
<d x="1"/>
<e width="50"/>
</Items>
</b>
<b name="test2" width="200">
<Items>
<d x="2"/>
</Items>
</b>
</Items>
</s>
I'm creating those classes
public class s
{
public s(){
Items=new List<b>();
}
List<b> Items{get;set;}
}
public class b
{
public b(){
Item=new List<object>();
}
[XmlAttribute]
public string name {get;set;}
[XmlAttribute]
public int width {get;set;}
}
public class d
{
public d(){}
[XmlAttribute]
public int x {get;set;}
}
public class e
{
public e(){}
[XmlAttribute]
public int width {get;set;}
}
And my main code is here
s mainobj=null;
XmlSerializer ser=new XmlSerializer(typeof(s));
mainobj=ser.Deserialize(memoryStream) as s;
Debug.WriteLine(mainobj.Items.Count.ToString());
Debug.WriteLine(mainobj.Items[0].name);
Debug.WriteLine(mainobj.Items[0].Items.Count.ToString());
Output
2
test
0
b
object items contains 2 type of object.
How to deserialize this objects.
What's wrong on my code?