Automatically minifying attribute/element names when using XmlSerializer
Posted
by frou
on Stack Overflow
See other posts from Stack Overflow
or by frou
Published on 2010-04-24T13:26:34Z
Indexed on
2010/04/24
13:43 UTC
Read the original article
Hit count: 274
When serializing a C# class using XmlSerializer, the attributes/elements representing the properties of the class will have the same names as they do in the source code.
I know you can override this by doing like so:
[XmlAttribute("num")]
public int NumberOfThingsThatAbcXyz { get; set; }
I'd like the generated XML for my classes to be as compact as possible, but obviously still capable of being automatically deserialized on the other side.
Is there a way to have these names minified as much as possible without having to manually think of and annotate everything with a short string? The resultant XML being easily human readable isn't a concern.
© Stack Overflow or respective owner