How can you control .NET DataContract serialization so it uses XML attributes instead of elements?
问题 If I have a class marked as a DataContract and a few properties on it marked with DataMember attributes I can serialize it out to XML easily, but it would create output like: <Person> <Name>John Smith</Name> <Email>john.smith@acme.com</Email> <Phone>123-123-1234</Phone> </Person> What I would prefer is attributes, like... <Person Name=\"John Smith\" Email=\"john.smith@acme.com\" Phone=\"123-123-1234\" /> The DataMember attribute allows me to control the Name and Order but not whether it is