title: How to use XmlElementAttribute for List<T>?
body: <p>I have a class like this:</p>
  
  <pre><code>public class Level
  {
      [XmlAttribute]
      public string Guid { get; set; }
  }
  
  public class LevelList : List&lt;Level&gt;
  {
  }
  
  public class Test
  {
      public LevelList CalLevelList { get; set; }
  }
  </code></pre>
  
  <p>Using XmlSerializer, I get the output like this:</p>
  
  <pre><code>      &lt;CalLevelList&gt;
          &lt;Level Guid="0de98dfb-ce06-433f-aeae-786b6d920aa6"/&gt;
          &lt;Level Guid="0de98dfb-ce06-433f-aeae-786b6d920aa7"/&gt;
        &lt;/CalLevelList&gt;
  </code></pre>
  
  <p>Which is technically correct. However, without changing the class names, I'd like to make the output look like this:</p>
  
  <pre><code>      &lt;Levels&gt;
          &lt;L Guid="0de98dfb-ce06-433f-aeae-786b6d920aa6"/&gt;
          &lt;L Guid="0de98dfb-ce06-433f-aeae-786b6d920aa7"/&gt;
        &lt;/Levels&gt;
  </code></pre>
  
  <p>I know this could be done through attributes, but couldn't figure out how. When I add an attribute to Test class like this:</p>
  
  <pre><code>    public class Test
      {
          [XmlElement("Levels")]
          public LevelList CalLevelList { get; set; }
      }
  </code></pre>
  
  <p>the output is quite surprising:</p>
  
  <pre><code>&lt;Levels Guid="0de98dfb-ce06-433f-aeae-786b6d920aa6"/&gt;
  &lt;Levels Guid="0de98dfb-ce06-433f-aeae-786b6d920aa7"/&gt;
  </code></pre>
  
  <p>That means, I lost the parent node. The elementname I specified becomes a node name. Why this? how to make it work?</p>