title: Deserialize XElement into Class(s)
body: <p>I am trying to Deserialize an XML file into a few class objects: Artist, Album, and Songs</p>
  <p>Here is the current setup:</p>
  <pre class="lang-cs prettyprint-override"><code>static void Main(string[] args)
  {
      var riseAgainst = DeSerializer(CreateElement());
      Console.WriteLine(string.Format(&quot;Band: {0}&quot;,riseAgainst.Name));
      Console.WriteLine(&quot;-----------------------------&quot;);
      Console.WriteLine(string.Format(&quot;Album: {0}&quot;,riseAgainst.Album.Name));
      Console.WriteLine(&quot;-----------------------------&quot;);
      Console.WriteLine(&quot;Song List:\r&quot;);
      
      foreach(var s in riseAgainst.Album.Songs)
      {
          Console.WriteLine(string.Format(&quot;Song: {0}&quot;, s));
      }
      Console.ReadLine();
  }
  
  static XElement CreateElement()
  {
      return new XElement(&quot;Artist&quot;,
                  new XElement(&quot;Name&quot;, &quot;Rise Against&quot;),
                  new XElement(&quot;Album&quot;,
                      new XElement(&quot;Name&quot;, &quot;Appeal to Reason&quot;),
                      new XElement(&quot;Songs&quot;,
                          new XElement(&quot;Song&quot;, &quot;Hero of War&quot;),
                          new XElement(&quot;Song&quot;, &quot;Savior&quot;))
                  )
              );
  }
  
  static Artist DeSerializer(XElement element)
  {
      var serializer = new XmlSerializer(typeof(Artist));
      return (Artist)serializer.Deserialize(element.CreateReader());
  }
  
  
  public class Artist
  {
      public string Name { get; set; }
      public Albums Album { get; set; }
  }
  
  public class Albums
  {
      public string Name { get; set; }
      public Songs Songs { get; set; }
  }
  
  public class Songs
  {
      public string Song { get; set; }
  }
  </code></pre>
  <p>The problem I currently have is if there is more than one Artist, Album, and/or Song then it only fills the first one. How can I make it so it fills them all for the album, or all the songs for the artist... etc I tried setting them up as Arrays but it didn't work. Thanks in advance.</p>