A must know in advance, i.e.
[XmlInclude(typeof(B))] public class A {...} public class B {...}
Now new XmlSerializer(typeof(A)) can serialize A or B You can also do this without attributes by passing the extraTypes parameter extraTypes overloaded XmlSerializer constructor, but again - the root should be A ; those. new XmlSeralializer(typeof(A), new[] {typeof(B)})
Marc gravell
source share