title: Populate a class from Linq to XML
body: <p>Ok, so I have an XML file that pretty much looks like this:</p>
  
  <pre><code> &lt;Templates&gt;
      &lt;Template&gt;
          &lt;TemplateID&gt;00X500000011iTSEAY&lt;/TemplateID&gt;
          &lt;To&gt;
              &lt;To type='User'&gt;00550000000mfOU&lt;/To&gt;
              &lt;To type='User'&gt;00550000000mb3pAAA&lt;/To&gt;
              &lt;To type='Group'&gt;00G50000001PiHz&lt;/To&gt;
              &lt;To type='AccountTeam'&gt;AccountExecutive&lt;/To&gt;
          &lt;/To&gt;
          &lt;CC&gt;
              &lt;CC type='AccountTeam'&gt;SalesLead&lt;/CC&gt;
          &lt;/CC&gt;
          &lt;BCC&gt;
              &lt;BCC type='SalesTeam'&gt;SalesManager&lt;/BCC&gt;
          &lt;/BCC&gt;
      &lt;/Template&gt;
  &lt;/Templates&gt;
  </code></pre>
  
  <p>With that, what I'm trying to do is to populate some classes that can make sense of that.  So the first thought I had was something like this for the To Elements:</p>
  
  <pre><code>public class EmailRecipient
  {
      public ToRecipient To {get;set;}
      public CCRecipient CC {get;set;}
  }
  
  public class ToRecipient
  {
      public string Key {get;set;}
      public string Type {get;set;}
  }
  </code></pre>
  
  <p>Not entirely elegant, but this is my rough draft.  I'm trying to use Linq to XML for this since I know what TemplateId I have, and then I can just populate the class with the values.  Here's where I'm at...and stuck in this test app:</p>
  
  <pre><code>var results = from x in xmlDoc.Descendants(XName.Get("Template")
                        where x.Element(XName.Get("TemplateID")).Value == "00X500000011iTSEAY"
                        select new EmailRecipient()
                          {
                              ToRecipient = 
                          };
  </code></pre>
  
  <p>With all of that being said, I'm looking to get a collection of "Tos" where each "to" can a "type" value. </p>
  
  <p>Any help would be greatly appreciated, I've done more in with XML in the past 3 days than have in the past 3 years, and that ain't much.</p>
  
  <p>Thanks so much for any help.</p>