Deserialiaze xml with same element but with different attributes and child elements



In the following code the tools that create automatically the xml parser classes always merge the fields:



<order>
<ItemType type="Clubs">
<Club num="1">
<ClubName>Some Name</ClubName>
<ClubChoice>Something Else</ClubChoice>
</Club>
</ItemType>
<ItemType type="Gift" val="MailGreeting">
<GiftName>MailGreeting</GiftName>
<GiftDescription></GiftDescription>
<GiftQuanity>1</GiftQuanity>
</ItemType


What I would like to have is something like this:



[XmlRoot("order")]
public class Order
{
[XmlElement("ItemType")]
public ClubType WhateverInstance { get; set; }

[XmlElement("ItemType")]
public GiftType SomethingInstance { get; set; }
}

No comments:

Post a Comment