title: How to serialize an included object/property as a root?
body: <p>I've got a tough problem. Let's say I have a class named <code>ObjectHost</code>, containing a property of type <code>BusinessObject</code>, which itself contains some properties (let's say a <code>Name</code> and a <code>Town</code> as strings).
  The code would be :</p>
  
  <pre><code>public class ObjectHost
  {
      public BusinessObject Data { get; set; }
  
      public ObjectHost()
      {
          Data = null;
      }
  
      public ObjectHost(BusinessObject ei)
      {
          Data = ei;
      }
  
      public override string ToString()
      {
          return (Data == null) ? "null" : Data.ToString();
      }
  }
  </code></pre>
  
  <p>When serializing, it will produce something like :</p>
  
  <pre><code>&lt;ObjectHost&gt;
    &lt;Data&gt;
      &lt;Name&gt;My name&lt;/Name&gt;
      &lt;Town&gt;London&lt;/Town&gt;
    &lt;/Data&gt;
  &lt;/ObjectHost&gt;
  </code></pre>
  
  <p>Where I'd like it to be :</p>
  
  <pre><code>&lt;Name&gt;My name&lt;/Name&gt;
  &lt;Town&gt;London&lt;/Town&gt;
  </code></pre>
  
  <p>as it is only an encapsulation object in my particular use (for some other purposes).</p>
  
  <p>I tried using <code>XmlRoot</code> and <code>XmlElement</code> attributes but I didn't achieve my goal.</p>
  
  <p>Is there a solution for this ?</p>