title: Serialize a C# class to XML with attributes and a single value for the class
body: <p>I am using C# and XmlSerializer to serialize the following class:</p>
  
  <pre><code>public class Title
  {
      [XmlAttribute("id")]
      public int Id { get; set; }
  
      public string Value { get; set; }
  }
  </code></pre>
  
  <p>I would like this to serialize to the following XML format:</p>
  
  <pre><code>&lt;Title id="123"&gt;Some Title Value&lt;/Title&gt;
  </code></pre>
  
  <p>In other words, I would like the Value property to be the value of the Title element in the XML file. I can't seem to find any way to do this without implementing my own XML serializer, which I would like to avoid. Any help would be appreciated.</p>