title: Remove XElement from XDocument
body: <p>I have an <code>XDocument</code> and i want to remove <code>XElement</code> from this.</p>
  
  <p>Please see the following code , Why not remove the <code>XElement</code> ?</p>
  
  <p>xml file :</p>
  
  <pre><code>&lt;Reports&gt;
    &lt;Report&gt;
      &lt;Id&gt;45f6bf21-d1b4-431b-818c-c1cb1c9bb221&lt;/Id&gt;
      &lt;Content&gt;Example 1&lt;/Content&gt;
      &lt;Date&gt;2014/10/11&lt;/Date&gt;
      &lt;Time&gt;18:03&lt;/Time&gt;
    &lt;/Report&gt;
    &lt;Report&gt;
      &lt;Id&gt;15c74518-64c0-459d-98a3-831734d96a76&lt;/Id&gt;
      &lt;Content&gt;Example 2&lt;/Content&gt;
      &lt;Date&gt;1393/10/12&lt;/Date&gt;
      &lt;Time&gt;04:00&lt;/Time&gt;
    &lt;/Report&gt;
    &lt;Report&gt;
      &lt;Id&gt;a2a48e10-4b16-4484-8402-c13a74af3981&lt;/Id&gt;
      &lt;Content&gt;Example 3&lt;/Content&gt;
      &lt;Date&gt;2014/10/13&lt;/Date&gt;
      &lt;Time&gt;03:36&lt;/Time&gt;
    &lt;/Report&gt;
  &lt;/Reports&gt;
  </code></pre>
  
  <p>service :</p>
  
  <pre><code> public class ReportService : IReportService
      {
          private readonly List&lt;Report&gt; allReports;
          private readonly XDocument data;
  
          public ReportService()
          {
              allReports = new List&lt;Report&gt;();
              data = XDocument.Load(HttpContext.Current.Server.MapPath("~/App_Data/Reports.xml"));
              var reports = from st in data.Descendants("Report")
                             select new Report
                               {
                                   Id = st.Element("Id").Value,
                                   Content = st.Element("Content").Value,
                                   Date = st.Element("Date").Value,
                                   Time = st.Element("Time").Value
                               };
              allReports.AddRange(reports.ToList());
          }
  
  
          public void Delete(string id)
          {
              Delete(d =&gt; d.Element("Id").ToString() == id);
          }
  
          public void Delete(Func&lt;XElement, bool&gt; @where)
          {
               data.Root.Elements("Report").Where(@where).Remove();
  
              data.Save(HttpContext.Current.Server.MapPath("~/App_Data/Reports.xml"));
          }
  
      }
      public interface IReportService
      {
          void Delete(string id);
          void Delete(Func&lt;XElement, bool&gt; @where);
      }
  </code></pre>
  
  <p>my code :</p>
  
  <pre><code>public class ReportsController : Controller
      {
          private readonly IReportService _reportService;
          public ReportsController()
          {
              _reportService = new ReportService();
          }
          public void Delete(string id)
          {
             _reportService.Delete(id);
          }
      }
  </code></pre>
  
  <p>no errors. But does not remove the <code>XElement</code> . How do I fix it?</p>
  
  <p>I need to remove an <code>XElement</code> from a <code>XDocument</code>.</p>