title: DataContractSerializer, EmitDefaultValue and empty tags
body: <p>I'm working on getting some objects serialized through an mvc site and returning things via xml, json, etc and I'm looking for the best way to not send the empty elements.</p>
  
  <p>In a perfect world, simply attaching EmitDefaultValue:=False to DataMembers in a DataContract would suffice, but in some situations, it just doesn't fly.</p>
  
  <p>A String default is Nothing, but I don't want to serialize them if they are Nothing or String.Empty. Same goes for lists and collections. I don't want them to serialize if they're Nothing or if they're empty with a count of 0.</p>
  
  <p>There seems to be a few not so pretty options.</p>
  
  <ol>
  <li>Custom <code>XmlTextWriter</code> that buffers itself and drops empty elements</li>
  <li>Before an object is serialized, cycle through the prop, setting Empty to Nothing, Count-0 to Nothing</li>
  <li>XSLT that drops empty elements</li>
  <li>Regex the output string on the way out</li>
  </ol>
  
  <p>All of these seem some what evil, 1 being the least evil but the leave trivial to do. Is there some other tricks out there?</p>