Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

want to use an XmlElement attribute on class?

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?

like image 598
Slee Avatar asked Oct 30 '25 15:10

Slee


1 Answers

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

like image 53
womp Avatar answered Nov 01 '25 14:11

womp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!