<p>I've got 2 Questions:</p>

<p>1.
I've sarted working around with Linq to XML and i'm wondering if it is possible to change an XML document via Linq. I mean, is there someting like </p>

<pre><code>XDocument xmlDoc = XDocument.Load("sample.xml");

update item in xmlDoc.Descendants("item")
where (int)item .Attribute("id") == id
...
</code></pre>

<p>2.
I already know how to create and add a new XMLElement by simply using </p>

<pre><code>xmlDoc.Element("items").Add(new XElement(......);
</code></pre>

<p>but how can I remove a single entry?</p>

<p>XML sample data:</p>

<pre><code>&lt;items&gt;
  &lt;item id="1" name="sample1" info="sample1 info" web="" /&gt;
  &lt;item id="2" name="sample2" info="sample2 info" web="" /&gt;
&lt;/itmes&gt;
</code></pre>

Is this what you have in mind?
```
```
using System;
using System.Linq;
using System.Xml.Linq;

static void Main(string[] args)
{
    string xml = @"<data><record id='1'/><record id='2'/><record id='3'/></data>";
    StringReader sr = new StringReader(xml);
    XDocument d = XDocument.Load(sr);

    // the verbose way, if you will be removing many elements (though in
    // this case, we're only removing one)
    var list = from XElement e in d.Descendants("record")
               where e.Attribute("id").Value == "2" 
               select e;

    // convert the list to an array so that we're not modifying the
    // collection that we're iterating over
    foreach (XElement e in list.ToArray())
    {
       e.Remove();
    }

    // the concise way, which only works if you're removing a single element
    // (and will blow up if the element isn't found)
    d.Descendants("record").Where(x => x.Attribute("id").Value == "3").Single().Remove();

    XmlWriter xw = XmlWriter.Create(Console.Out);
    d.WriteTo(xw);
    xw.Flush();
    Console.ReadLine();
}
```
```