[Serializable]
public abstract a
{
private string _name = string.empty;
[XmlAttribute()]
public string Name
{
get{ return _name;}
set{ _name = value;}
}
}
[Serializable]
public class AA:a
{
.......
}
[Serializable]
public class BB :a
{
........
}
[Serializable]
public class XX
{
private List<a> _children = new List<a>();
[System.Xml.Serialization.XmlArray("as")]
[System.Xml.Serialization.XmlArrayItem("AA", typeof(AA)),
System.Xml.Serialization.XmlArrayItem("BB", typeof(BB))]
public List<a> Children
{
get{ return _children;}
set{_children = value;}
}
}
public Main()
{
XX x = new XX();
x.Children.add( new AA());
x.Children.add( new BB());
XmlSerializer s = new XmlSerializer( x.gettype() );
using ( stringWrite w = new stringwriter() )
{
w.Serialize( w , xx.gettype() );
}
}
public abstract a
{
private string _name = string.empty;
[XmlAttribute()]
public string Name
{
get{ return _name;}
set{ _name = value;}
}
}
[Serializable]
public class AA:a
{
.......
}
[Serializable]
public class BB :a
{
........
}
[Serializable]
public class XX
{
private List<a> _children = new List<a>();
[System.Xml.Serialization.XmlArray("as")]
[System.Xml.Serialization.XmlArrayItem("AA", typeof(AA)),
System.Xml.Serialization.XmlArrayItem("BB", typeof(BB))]
public List<a> Children
{
get{ return _children;}
set{_children = value;}
}
}
public Main()
{
XX x = new XX();
x.Children.add( new AA());
x.Children.add( new BB());
XmlSerializer s = new XmlSerializer( x.gettype() );
using ( stringWrite w = new stringwriter() )
{
w.Serialize( w , xx.gettype() );
}
}