如何编写一个xpath语句来查找父元素不是衬衫元素的size属性的所有实例?
<?xml version="1.0" encoding="utf-8" ?>
<Clothing>
<Shirts>
<Shirt size="Large"></Shirt>
<Shirt size="Medium"></Shirt>
<Shirt size="Small"></Shirt>
</Shirts>
<Pants>
<Shorts>
<Khakis>
<Khaki size="34"></Khaki>
<Khaki size="32"></Khaki>
</Khakis>
<Plaids>
<Plaid size="big"></Plaid>
<Plaid size="just right"></Plaid>
</Plaids>
</Shorts>
<Jeans></Jeans>
</Pants>
<Shoes>
<Sandal size="Large"></Sandal>
<Sandal size="Medium"></Sandal>
<Sandal size="Small"></Sandal>
</Shoes>
</Clothing>
答案 0 :(得分:2)
使用parent::
轴Shirt
nodetest,使用not
取消谓词。
//@size[not(parent::Shirt)]