title: LINQ: Remove Element from XML based on attribute value?
body: <p>How can I remove any element in xml based on matched attribute value?</p>
  
  <p>Here is my XML :</p>
  
  <pre><code>&lt;Projects&gt;
      &lt;Project serverUrl="tcp://xyz1:xxx/sdfsdf.rem" projectName="project1" /&gt;
      &lt;Project serverUrl="tcp://xyz2:xxx/sdfsdf.rem" projectName="project2" /&gt;
      &lt;Project serverUrl="tcp://xyz3:xxx/sdfsdf.rem" projectName="project3" /&gt;
      &lt;Project serverUrl="tcp://xyz4:xxx/sdfsdf.rem" projectName="project4" /&gt;
      &lt;Project serverUrl="tcp://xyz5:xxx/sdfsdf.rem" projectName="project5" /&gt;
      &lt;Project serverUrl="tcp://xyz6:xxx/sdfsdf.rem" projectName="project6" /&gt;
     &lt;/Projects&gt;
  </code></pre>
  
  <p>I am using the following LINQ query:</p>
  
  <pre><code>var remove = from elemet in xdoc.Elements("Projects").Elements("Project")
                                   where elemet.Attribute("projectName").Value == "project1"
                                   select elemet.Parent.Remove();
  </code></pre>
  
  <p>I am getting compile time error on select as : </p>
  
  <blockquote>
    <p>The type of expression in select
    clause is Incorrect</p>
  </blockquote>
  
  <p>EDIT ANSWER:
  this one works for me. Thanks All</p>
  
  <pre><code>var xElement = (from elemet in xdoc.Elements("Projects").Elements("Project")
                              where elemet.Attribute("projectName").Value == foundProject
                              select elemet);
              xElement.Remove();
  </code></pre>