XElement xmlTree = new XElement("Barcodes",
new XElement("sample1 ", new XAttribute("ScanPegStatus", "aa")),
 new XElement("sample2", new XAttribute("ScanPegStatus", "bb")),
  new XElement("sample3", new XAttribute("ScanPegStatus", "cc"))
);XElement xmlTree2 = new XElement("Barcodes",
    from el in xmlTree1.Elements()
    where(el.Attributes["Id"]=='001'  && (int)el.Attributes["sample"]  == "333")
    select el
);我没测试
你自己慢慢尝试下吧