title: Linq To Xml Null Checking of attributes
body: <pre><code>&lt;books&gt;
     &lt;book name="Christmas Cheer" price="10" /&gt;
     &lt;book name="Holiday Season" price="12" /&gt;
     &lt;book name="Eggnog Fun" price="5" special="Half Off" /&gt;
  &lt;/books&gt;
  </code></pre>
  
  <p>I'd like to parse this using linq and I'm curious what methods other people use to handle special. My current way of working with this is:</p>
  
  <pre><code>var books = from book in booksXml.Descendants("book")
                          let Name = book.Attribute("name") ?? new XAttribute("name", string.Empty)
                          let Price = book.Attribute("price") ?? new XAttribute("price", 0)
                          let Special = book.Attribute("special") ?? new XAttribute("special", string.Empty)
                          select new
                                     {
                                         Name = Name.Value,
                                         Price = Convert.ToInt32(Price.Value),
                                         Special = Special.Value
                                     };
  </code></pre>
  
  <p>I am wondering if there are better ways to solve this.</p>
  
  <p>Thanks,</p>
  
  <ul>
  <li>Jared</li>
  </ul>