I've got an xml file with a collection that looks like this
<AbstractCollection>
<ConcreteA name="Bob" age="4"/>
<ConcreteB name="Tree" size="1" />
</AbstractCollection>
I know that if I use a concrete collection - i.e. the two elements were the same type - it would be easy to use the standard XML deserialisation in C#. The different types seem to make it more difficult.
Is there a way to use the simple xml deserialisation to get this out, or do I have to implement deserialisation myself?
[Added for clarity] I should add that the xml already exists and I can't change it. I'm receiving messages in xml that take a form like that above. A more concrete example would be:
<Actions>
<Walked name="Bob" distance="4"/>
<Cycled name="Jane" gear="3rd" />
</Actions>
What I want to end up with is a "Cycled" and a "Walked" object. Oh, and to make it extra fun, the order is important.
Also, I've tried using XmlInclude attributes in the code, but that works by changing the xml when you serialise it (unless I've been using it wrong of course).