title: NullReferenceException in LINQ to XML query
body: <p>I have xml code that would be something like this:
  file named: player.xml</p>
  
  <pre><code>&lt;root&gt;
    &lt;person&gt;
      &lt;fname&gt;Dwight&lt;/fname&gt;
      &lt;lname&gt;Howard&lt;/lname&gt;
      &lt;vertLeap&gt;
        &lt;try1&gt;32.33&lt;/try1&gt;
        &lt;try2&gt;33.33&lt;/try2&gt;
        &lt;try3&gt;34.33&lt;/try3&gt; 
      &lt;/vertLeap&gt;
    &lt;/person&gt;
    &lt;person&gt;
      &lt;fname&gt;&lt;/fname&gt;
      &lt;lname&gt;Jordan&lt;/lname&gt;
      &lt;vertLeap&gt;
        &lt;try1&gt;40.33&lt;/try1&gt; 
      &lt;/vertLeap&gt;
    &lt;/person&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>This isn't my real xml, but should work for the example.
  Now I want to use linq to xml to read the data.  Iam am trying like this.</p>
  
  <p>Class:</p>
  
  <pre><code>public class Player
  {
      public string FirstName { get; set; }
      public string LastName { get; set; }
      public int Leap1 { get; set; }
      public int Leap2 { get; set; }
      public int Leap3 { get; set; }
  
      public WritePlayertoDatabase()
      {
          //do stuff to write
      }
  }
  </code></pre>
  
  <p>Query:</p>
  
  <pre><code>XDocument xDoc = XDocument.Load("player.xml");
  var player_query = from p xDoc.Desendants("person")
                     select new Player
                     {
                         FirstName = p.Element("fname"),
                         LastName = p.Element("lname"),
                         Leap1 = p.Element("try1"),
                         Leap2 = p.Element("try2"),
                         Leap3 = p.Element("try3")
                     };
  </code></pre>
  
  <p>I'm getting a NullReferenceException. Is there a way to test if the elements exist before I try to use the value?  Or is there a way better way to accomplish this?</p>