I have XML that looks something like this:
<root>
<base type="a">
<common>1</common>
<concreteA>one</concreteA>
</base>
<base type="b">
<common>2</common>
<concreteB>two</concreteB>
</base>
</root>
And classes like this:
public class Root
{
public List<Base> Bases { get; set; }
}
public class Base
{
public int Common { get; set; }
}
public class A : Base
{
public string ConcreteA { get; set; }
}
public class B : Base
{
public string ConcreteB { get; set; }
}
How can I deserialize this into objects? I've seen many posts on how to do it when each base node has a different name using XmlArrayItemAttribute( ElementName, Type )]
, but I need to choose it based on the elements type
attribute instead.