If I have a class marked as DataContract and several properties on it marked with DataMember , I can easily serialize it to XML, but it would produce output, for example:
<Person> <Name>John Smith</Name> <Email>john.smith@acme.com</Email> <Phone>123-123-1234</Phone> </Person>
What I would like are attributes, for example ...
<Person Name="John Smith" Email="john.smith@acme.com" Phone="123-123-1234" />
The DataMember allows me to control the name and order, but not be serialized as an element or attribute. I looked around and found DataContractFormat and IXmlSerializable , but I hope there is an easier solution there.
What is the easiest way to do this?
Brennan Feb 26 '09 at 18:47 2009-02-26 18:47
source share