Xml enum as an attribute
Is there any method to serialize an enum member into the attribute of an
xml? I have the following class and its related enum
public class contract
{
[XmlArray(ElementName = "ContractFeatures")]
[XmlArrayItem(ElementName = "Features")]
public List<ContractFeaturesEnum> ContractFeatures;
}
and here is my enum:
public enum ContractFeaturesEnum
{
[EnumMember]
[XmlEnum(Name = "0")]
Feature1 = 0,
[EnumMember]
[XmlEnum(Name = "1")]
Feature1 = 1
}
my serialized output is
<ContractFeatures>
<Features>1</Features>
<Features>2</Features?
</ContractFeatures>
but the output that I need is like this:
<ContractFeatures>
<Feature ID="1"/>
<Feature ID="2"/>
</ContractFeatures>
and one more thing ... I don't want to add a new class and add
xmlAttribute for its properties. Thank you for your help in advanced.
No comments:
Post a Comment