I need to deserialize XML containing elements in one of the following three forms:
<Element1>xxx</Element1>
or
<Element2>xxx</Element2>
or
<Element1>xxx</Element1>
<Element2>xxx</Element2>
If both are present I need to use value of Element1 in preference to Element2. How can I do that?
I am using System.Xml.Serialization to parse the xml This is my property
[XmlElement("Element1")]
[XmlElement("Element2")]
public string Data
{
get
{
return this.data;
}
set
{
this.data = value;
}
}
In my case, I need to use Element1 if both are present, else use the one which is present.
I was not able to come up with the solution for this.
Try this.