title: Xml serialization - collection attribute
body: <p>HelIo,</p>
  
  <p>This code:</p>
  
  <pre><code>[Serializable]
  [XmlRoot("A")]
  public class A
  {
      public B B { get; set; }
  
      public void Save()
      {
          string settingsFilePath = string.Format("test.xml");
          XmlSerializer serializer = new XmlSerializer(typeof(A));
          TextWriter writer = new StreamWriter(settingsFilePath);
          XmlSerializerNamespaces ns = new XmlSerializerNamespaces(new XmlQualifiedName[] { new XmlQualifiedName(string.Empty) });
          serializer.Serialize(writer, this, ns);
          writer.Close();
      }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>public class B
  {
      [XmlAttribute("c")]
      public string C { get; set; }
  
      public List&lt;D&gt; D { get; set; }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>public class D
  {
      [XmlAttribute("e")]
      public string E { get; set; }
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>A a = new A();
  a.B = new B();
  a.B.C = "c";
  a.B.D = new List&lt;D&gt;();
  D d = new D();
  d.E = "e";
  a.B.D.Add(d);
  a.B.D.Add(d);
  a.B.D.Add(d);
  a.Save();
  </code></pre>
  
  <p>generates such xml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;A&gt;
    &lt;B c="c"&gt;
      &lt;D&gt;
        &lt;D e="e" /&gt;
        &lt;D e="e" /&gt;
        &lt;D e="e" /&gt;
      &lt;/D&gt;
    &lt;/B&gt;
  &lt;/A&gt;
  </code></pre>
  
  <p>Is there any way to generate xml with such structure: ?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;A&gt;
    &lt;B c="c"&gt;
       &lt;D e="e" /&gt;
       &lt;D e="e" /&gt;
       &lt;D e="e" /&gt;
    &lt;/B&gt;
  &lt;/A&gt;
  </code></pre>