public static void Main()
@"<?xml version=""1.0""?>
<!-- comment at the root level -->
<Child key='target'>Content</Child>
XDocument doc = XDocument.Parse(str);
foreach (XElement element in doc.Descendants("RootChild2"))
if (element.HasAttributes && element.Element("Child").Attribute("key").Value == "target")
Console.WriteLine("found it");
Console.WriteLine("not found");