title: XML Serialization List of Objects
body: <p>Looking at the Microsoft article on XML Serialization:</p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/58a18dwa.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/58a18dwa.aspx</a></p>
  
  <p>They give an example under "Serializing an Array of Objects" as below:</p>
  
  <pre><code>public class PurchaseOrder
  {
      public Item [] ItemsOrders
  }
  
  public class Item
  {
      public string ItemID
      public decimal ItemPrice
  }
  </code></pre>
  
  <p>With output:</p>
  
  <pre><code>&lt;PurchaseOrder&gt;
      &lt;Items&gt;
          &lt;Item&gt;
              &lt;ItemID&gt;aaa111&lt;/ItemID&gt;
              &lt;ItemPrice&gt;34.22&lt;/ItemPrice&gt;
          &lt;/Item&gt;
          &lt;Item&gt;
              &lt;ItemID&gt;bbb222&lt;/ItemID&gt;
              &lt;ItemPrice&gt;2.89&lt;/ItemPrice&gt;
          &lt;/Item&gt;
      &lt;/Items&gt;
  &lt;/PurchaseOrder&gt;
  </code></pre>
  
  <p>What bothers me is the "Items" tag.  Seems to me like only the "Item" tag should be a child of "PurchaseOrder".  The "Items" tag seems unnecessary and confusing.  I could be wrong.</p>
  
  <p>Is there a way to get this example to serialize like this:</p>
  
  <pre><code>&lt;PurchaseOrder&gt;
      &lt;Item&gt;
          &lt;ItemID&gt;aaa111&lt;/ItemID&gt;
          &lt;ItemPrice&gt;34.22&lt;/ItemPrice&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;ItemID&gt;bbb222&lt;/ItemID&gt;
          &lt;ItemPrice&gt;2.89&lt;/ItemPrice&gt;
      &lt;/Item&gt;
  &lt;/PurchaseOrder&gt;
  </code></pre>