Reputation: 10959
In researching the serialization of .NET objects -- be they native or custom classes -- I've noticed that people put XML-specific attributes on the class and its members. However, when I seriliaze a custom class to XML for the purpose of saving customizable application settings, I never use such attributes and it serializes and deserializes just fine using XmlSerializer. Is the purpose of XML attributes just to be able to customize the output of the XML or is there a time when not using attributes can be to the detriment of output to an XML fuke?
Upvotes: 0
Views: 46
Reputation: 236308
Those attributes affect not only serialization, but also deserialization. And because you often already have some xml schema which you can't change, you can apply xml attributes to control deserializaton of some objects from existing xml. Also xml attributes are useful when xml and .net classes have different naming standards, or when xml schema and your .net classes are changed independently.
Upvotes: 1