title: Renaming array items in a flat xml array using an XmlSerializer
body: <p>I have an XML file with the following format:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Items&gt;
      &lt;Item Property1="A" Property2="B" /&gt;
      &lt;Item Property1="C" Property2="D" /&gt;
  &lt;/Items&gt;
  </code></pre>
  
  <p>I need to read the <code>&lt;Item&gt;</code> elements as objects of class <code>MyClass</code> using an XmlSerializer.</p>
  
  <pre><code>public class MyCLass
  {
      [XmlAttribute]
      public string Property1 { get; set; }
  
      [XmlAttribute]
      public string Property2 { get; set; }
  }
  </code></pre>
  
  <p>Currently, I have the following code to read the file:</p>
  
  <pre><code>XmlSerializer serializer =
      new XmlSerializer(typeof(MyClass[]), new XmlRootAttribute(@"Items"));
  
  MyClass[] list = (MyClass[])serializer.Deserialize(...);
  </code></pre>
  
  <p>Since the element name <code>&lt;Item&gt;</code> is different from the class name <code>MyCLass</code>, the elements in the array are not deserialized at all. The above code works if I rename <code>MyClass</code> to <code>Item</code>, but unfortunately I am not allowed to change the XML file or the class names.</p>
  
  <p>How do I go about mapping the two so that the file can be read correctly?</p>
  
  <p>Thanks in advance!</p>