I have some XML which looks like this:
<Stat Type="first_name">[Value]</Stat>
<Stat Type="last_name">[Value]</Stat>
<Stat Type="known_name">[Value]</Stat>
I want to deserialize this to an object. As there is one element name called “Stat” it’s making it difficult to get something like:
[XmlAttribute("first_name")]
public string FirstName{get;set;}
[XmlAttribute("last_name")]
public string LastName{get;set;}
[XmlAttribute("known_name")]
public string KnownName{get;set;}
Is there a way of getting the XML above into an object like:
public string FirstName{get;set;}
public string LastName{get;set;}
public string KnownName{get;set;}
Thanks.
I managed to solve this by using an extension. Not ideal. I get the list of stats:
Then I have separate properties like:
The GetStat extension method on the Stats property then gets the relevant key. Unfortunately, this way, it will run through that list for each property I want to get.