title: How do I deserialize this XML back into an array of Point objects
body: <p>The XML file is as follows</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;Polygons&gt;    
    &lt;Polygon&gt;
      &lt;Points&gt;
        &lt;Point2D X="0" Y="0" /&gt;
        &lt;Point2D X="100" Y="0" /&gt;
        &lt;Point2D X="100" Y="200" /&gt;
        &lt;Point2D X="0" Y="200" /&gt;
      &lt;/Points&gt;
    &lt;/Polygon&gt;
    &lt;Polygon&gt;
      &lt;Points&gt;
        &lt;Point2D X="0" Y="0" /&gt;
        &lt;Point2D X="100" Y="0" /&gt;
        &lt;Point2D X="100" Y="200" /&gt;
        &lt;Point2D X="0" Y="200" /&gt;
      &lt;/Points&gt;
    &lt;/Polygon&gt;
  &lt;/Polygons&gt;
  </code></pre>
  
  <p>I want to deserialize this XML back into Polygon objects. My Polygon class is as follows</p>
  
  <pre><code>[XmlType("Polygon")]
  public class Polygon
  {
      [XmlElement("Points")]
      public Point[] points { get; set; }
  }
  </code></pre>
  
  <p>My deserialization code is</p>
  
  <pre><code>XmlSerializer serializer = new XmlSerializer(typeof(Polygon[]),new XmlRootAttribute("Polygons"));
  FileStream fs = new FileStream(filename, FileMode.Open);
  XmlReader reader = XmlReader.Create(fs);
  Polygon[] p;
  p = (Polygon[])serializer.Deserialize(reader);
  fs.Close();
  </code></pre>
  
  <p>I've so far managed a workaround by creating a <code>Point2D</code> class with X and Y attributes and then creating Point objects using them. Is there any way to directly assign the attributes listed under Point2D to Point objects like <code>pointObject.X</code> and <code>pointObject.Y</code>?</p>