using System;
using System.Linq;
using System.Xml.Linq;
using System.Xml;
public class Program
{
public static void Main()
string xml = @"
<result>
<product>
<auto>
<report>
<admin></admin>
<search>
<subjects>
<subject>
<name>
<first>John</first>
<last>D</last>
</name>
</subject>
</subjects>
</search>
</report>
</auto>
<first>Jack</first>
<last>L</last>
</product>
</result>";
string first = "John";
string last = "D";
XDocument xd = XDocument.Parse(xml);
xd.Root.Element("product").Elements("auto").ToList()
.ForEach(x=>
var name = x.Descendants("name").First();
if (name.Element("first").Value != first
&& name.Element("last").Value != last)
x.Remove();
});
Console.WriteLine(xd);
}