I’d like to declare both XmlAttributeAttribute and XmlElementAttribute on a property so that the xml deserializes correctly regardless of whether the property is defined as an xml element or as an xml attribute.
e.g.
given
public class X
{
[XmlElement()]
[XmlAttribute()]
public string Prop
{
get;
set;
}
}
either of the following deserialize correctly:
<X>
<Prop>XXX</Prop>
</X>
<X Prop="XXX"/>
Is this possible?
You can introduce a forwarding property like this