Assuming that by specifying the ancestor of the element, you are referencing the element with children, this XPath expression should do:
//*[*/ccc][@att != 'xyz']
He is choosing
- all nodes
- who have at least one
<ccc>
grandson node - and have the attribute
att
whose value is not xyz
.
Update: The limited test for grandparents <ccc>
.
Update 2: Adapted to your revised question:
//ccc[../parent::aaa/@att != 'xyz']
The choice
- all
<ccc>
elements - who have grandparent
<aaa>
with their att
attribute set to a value that is not xyz
source share