title: LINQ to XML Append Data throws null reference exception
body: <p>Here's the problem I have a xml file that I am trying to append data to.  I am using LINQ to XML and the code I am using is as follows:</p>
  
  <pre><code>    public void AppendSalesXMLData(Company company)
      {
          string FileName = "TestSales";
          string OrgID = company.OrgID.ToString();
          string SaleID = company.OrgSales[company.OrgSales.Count - 1].SaleID.ToString();
  
          if (!File.Exists(String.Format(@"C:\Data-Source\trunk\Applications\VintageSiteInspector\XML\{0}.xml", FileName)))
          {
              CreateXMLFile(FileName);
          }
          XDocument thisDoc = XDocument.Load(String.Format(@"C:\Data-Source\trunk\Applications\VintageSiteInspector\XML\{0}.xml", FileName));
  
          &lt;!------- The following line throws an exception every time. -----&gt;
          thisDoc.Element(FileName).Add(new XElement("Sale")); 
  
  
          thisDoc.Save(String.Format(@"C:\Data-Source\trunk\Applications\VintageSiteInspector\XML\{0}.xml", FileName));
      }
  </code></pre>
  
  <p>The XML file that I am opening is </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;root&gt;
   &lt;TestSales&gt;&lt;/TestSales&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>I just don't see why I am getting a null reference exception.  </p>