I'm having trouble with XML deserialization in C#.
I have the following XML:
<?xml version="1.0" encoding="utf-8"?>
<head>
<person>
<name>Jim Bob</name>
<dateOfBirth>1990-01-01</dateOfBirth>
</person>
<policy>
<number>1</number>
<pet>
<name>Snuffles</name>
<dateOfBirth>2000-01-01</dateOfBirth>
</pet>
</policy>
</head>
With this I'm trying to map it to the following classes:
public class head
{
public policy policy { get; set; }
public person person { get; set; }
}
public class person
{
public string name { get; set; }
public DateTime dateOfBirth { get; set; }
[XmlElement("policy")]
public List<policy> policy { get; set; }
}
public class policy
{
public string number { get; set; }
[XmlElement("pet")]
public List<pet> pet { get; set; }
}
public class pet
{
public string name { get; set; }
[XmlElement("dateOfBirth")]
public DateTime dateOfBirth { get; set; } //<~~ Issue is with this property
}
The issue is that the dateOfBirth property in the pet class isn't being populated when being deserialized and I don't know why. Is this because of a naming conflict with the dateOfBirth property in the person class?