This is the code that I've used to write the data from the List to the XML file:

```
using (FileStream f = new FileStream(@"animals.xml", FileMode.Create, FileAccess.Write))
            {
                var dcsw = new DataContractSerializer(typeof(List<Animal>));
                XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(f);

                try
                {
                    dcsw.WriteObject(f, animalList);
                    writer.Close();
                    f.Close();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }

```

This is an example of my XML file:

```
<ArrayOfAnimal xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/AnimalShelter">
<Animal i:type="Cat">
<ChipRegistrationNumber>12346</ChipRegistrationNumber>
<DateOfBirth>
<date>1234-11-11T00:00:00</date>
</DateOfBirth>
<IsReserved>false</IsReserved>
<Name>Yoshi</Name>
<BadHabits>Scratches</BadHabits>
<Price>51</Price>
</Animal>

<Animal i:type="Dog">
<ChipRegistrationNumber>12347</ChipRegistrationNumber>
<DateOfBirth>
<date>1234-11-11T00:00:00</date>
</DateOfBirth>
<IsReserved>false</IsReserved>
<Name>Sonic</Name>
<LastWalkDate>
<date>1234-11-11T00:00:00</date>
</LastWalkDate>
<Price>200</Price>
</Animal>
</ArrayOfAnimal>

```

As you can see, Cat has a a node called "BadHabits" and Dog has a different one called "LastWalkDate".

"Cat" and "Dog" inherit from the class Animal. 

I've seen many examples of parsing strings to a List.. That's quite do-able.. but my list has different types like a custom date class

Example of an instance of Animal: 

```
SimpleDate date1 = new SimpleDate(11, 11, 1234);
Animal cat1 = new Cat("12346", date1, "Yoshi", "Scratches");

```

How am I able to parse all the cats and dogs from the XML file in a `List<Animal>`?