title: WCF XML Serialization
body: <p>Back in the days of 2.0 serialization I could create a serialized version of an object that would result in the following example:</p>
  
  <pre><code>&lt;transactionMessage messageDate="1/1/2001 11:00PM" messageId="abc123"&gt;
      &lt;transaction property1="Value" property2="value2" /&gt;
  &lt;/transactionMessage&gt;
  </code></pre>
  
  <p>I would do this with the Serializable() attribute and then appending XmlElement attributes to my items. When I use DataContract/DataMember attributes though, I get something that looks like this:</p>
  
  <pre><code>&lt;transactionMessage&gt;
    &lt;messageDate&gt;1/1/2001 11:00PM&lt;/messageDate&gt;
    &lt;messageId&gt;abc123&lt;/mesageId&gt;
    &lt;transaction&gt;
      &lt;property1&gt;Value&lt;/property1&gt;
      &lt;property2&gt;Valu2&lt;/property2&gt;
    &lt;/transaction&gt;
  &lt;/transactionMessage&gt;
  </code></pre>
  
  <p>Ordinarily I wouldn't really care about the XML being generated behind the scenes, but this system will be interfacing with multiple external clients who already talk to a different system (based on the 2.0 style of serialization) and I want to keep the structure similar but bring in the added enhancements of WCF.</p>
  
  <p>How can I tell the DataMember attribute to essentially make the formatting more like the first sample with attributes instead of elements for everything?</p>