Simple: find all the
<p>
nodes that don't have an
<x>
node as their immediate parent.
IEnumerable<XElement> invalidNodes = document.Descendants("p").Where(p => p.Parent.Name != "x");
Or, if the
<p>
node can be nested at any depth under an
<x>
node, check the ancestors:
IEnumerable<XElement> invalidNodes = document.Descendants("p").Where(p => !p.Ancestors("x").Any());