want to use an XmlElement attribute on class?

asp.net, serialization, xml

Solution

I think you're looking for the XmlTypeAttribute if you want to change how a class is serialized.

Problem

I have the following class: ``` [XmlElement("email-address")] public class EmailAddress { public string address { get; set; } public string location { get; set; } } ``` The XmlElement attribute is in valid here, but I do want this behavior - is this possible? TO have the name of this class serialized in XML as `email-address` instead of `EmailAddress`?

Original source