title: C# XML Serializable Collection
body: <p>I got the below XML (It is just a part of a big XML where I have my problem) that I am trying to make a Serializable class to read the same.</p>
  
  <pre><code>&lt;BANKTRANLIST&gt;
    &lt;DTSTART&gt;20051001&lt;/DTSTART&gt;
    &lt;DTEND&gt;20051028&lt;/DTEND&gt;
    &lt;STMTTRN&gt; &lt;!-- This element can repeat any number of times --&gt;
      &lt;TRNTYPE&gt;CHECK&lt;/TRNTYPE&gt;
      &lt;DTPOSTED&gt;20051004&lt;/DTPOSTED&gt;
      &lt;TRNAMT&gt;-200.00&lt;/TRNAMT&gt;
    &lt;/STMTTRN&gt;
    &lt;STMTTRN&gt;
      &lt;TRNTYPE&gt;ATM&lt;/TRNTYPE&gt;
      &lt;DTPOSTED&gt;20051020&lt;/DTPOSTED&gt;
      &lt;TRNAMT&gt;-300.00&lt;/TRNAMT&gt;
    &lt;/STMTTRN&gt;
  &lt;/BANKTRANLIST&gt;
  </code></pre>
  
  <p><strong>My C# Implementation</strong></p>
  
  <pre><code>[Serializable]
  [XmlRoot("BANKTRANLIST", Namespace = "http://bank.net", IsNullable = false)]
  public class BankTransactionList
  {
      public BankTransactionList()
      {
          this.StatementTransactions = new List&lt;StatementTransaction&gt;();
      }
  
      [XmlElement("DTSTART")]
      public string StartDate { get; set; }
  
      [XmlElement("DTEND")]
      public string EndDate { get; set; }
  
      [XmlArray("STMTTRN")]
      [XmlArrayItem("STMTTRN")]
      public List&lt;StatementTransaction&gt; StatementTransactions { get; set; }
  }
  
  
  [Serializable]
  [XmlRoot("STMTTRN", Namespace = "http://bank.net", IsNullable = false)]
  public class StatementTransaction
  {
      // TransactionType : ENUM
      [XmlElement("TRNTYPE")]
      public TransactionType TransactionType { get; set; }
  
      [XmlElement("DTPOSTED")]
      public string DatePosted { get; set; }
  
      [XmlElement("TRNAMT")]
      public double TransactionAmount { get; set; }
  }
  </code></pre>
  
  <p><strong>My problem</strong> is  element wrapped again in  element which results to get the below output</p>
  
  <pre><code>...
      &lt;STMTTRN&gt; &lt;!-- This does not match my Original XML --&gt;
        &lt;STMTTRN&gt;
          &lt;TRNTYPE&gt;CHECK&lt;/TRNTYPE&gt;
          &lt;DTPOSTED&gt;20051004&lt;/DTPOSTED&gt;
          &lt;TRNAMT&gt;-200.00&lt;/TRNAMT&gt;
        &lt;/STMTTRN&gt;
        &lt;STMTTRN&gt;
          &lt;TRNTYPE&gt;ATM&lt;/TRNTYPE&gt;
          &lt;DTPOSTED&gt;20051020&lt;/DTPOSTED&gt;
          &lt;TRNAMT&gt;-300.00&lt;/TRNAMT&gt;
        &lt;/STMTTRN&gt;
      &lt;/STMTTRN&gt;
  </code></pre>
  
  <p>Note: Removing [XmlArray("STMTTRN")] tag from List property will not resolve this, instead  it will be </p>
  
  <p>If any one can <strong>correct</strong> me or give me a better solution would be great !! </p>