Reputation: 988
I want to serialize an object where one of the attributes maps to 2 xml elements. I'm creating a program that interfaces with a wifi account management system through its RESTful API. Here is the object that I need to serialize to create the account:
[XmlRoot("record")]
class XmlUser
{
[XmlElement("login")]
public string Username { get; set; }
[XmlElement("password")]
[XmlElement("password_confirmation")]
public string Password { get; set; }
// Other attributes...
}
Having two XmlElementAttributes
on one attribute throws an exception, saying I need to add the XmlChoiceIdentifierAttribute
. I don't need to deserialize the object. Should I abandon this method, and just use a XmlWriter
?
Upvotes: 0
Views: 64
Reputation: 296
You can do,
[XmlElement("password")]
public string Password { get; set; }
[XmlElement("password_confirmation")]
public string PasswordConfirmation{ get { return Password;} set; }
Upvotes: 2