title: LINQ to XML using Lambda syntax to populate object collection
body: <p>I am trying to use LINQ with lambda syntax to load a List of objects from an XML fragment but I am having trouble with the lambda syntax in creating the new object.</p>
  
  <p>Here is the custom class that will hold the data:</p>
  
  <pre><code>public class PhysicianInfoModel
  {
    string FirstName;
    string LastName;
    string Degree;
  }
  </code></pre>
  
  <p>Here is the sample XML I am trying to load the object collection from:</p>
  
  <pre><code>&lt;response&gt;
    &lt;control&gt;
      &lt;status&gt;success&lt;/status&gt;
      &lt;dtdversion&gt;3.0&lt;/dtdversion&gt;
    &lt;/control&gt;
    &lt;operation&gt;
      &lt;authentication&gt;
        &lt;status&gt;success&lt;/status&gt;
        &lt;userid&gt;jsmith&lt;/userid&gt;
      &lt;/authentication&gt;
      &lt;result&gt;
        &lt;status&gt;success&lt;/status&gt;
        &lt;physicianlist&gt;
          &lt;physician&gt;
            &lt;lastname degree="MD"&gt;Smith&lt;/lastname&gt;
            &lt;firstname&gt;Paul&lt;/firstname&gt;
          &lt;/physician&gt;
          &lt;physician&gt;
            &lt;lastname degree="DO"&gt;Smith&lt;/lastname&gt;
            &lt;firstname&gt;Paul&lt;/firstname&gt;
          &lt;/physician&gt;
        &lt;/physicianlist&gt;
      &lt;/result&gt;
    &lt;/operation&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>I have tried using code such as the following but I know it is not correct as even intellisense in Visual Studio is going all "red squiggly line". In this example <code>xml</code> is an <code>XDocument</code> object that has loaded the XML listed above.</p>
  
  <pre><code>List&lt;PhysicianInfoModel&gt; nodeList = xml.Descendants("physicianlist")
                                  .Descendants("physician")
                                  .Select(x =&gt; new PhysicianInfoModel()
                                  {
                                    FirstName = x.?????,
                                    LastName = x.????,
                                    Degree = x.Attribute("degree") // Not working
                                  });
  </code></pre>