如何编写一个xpath语句来查找父元素不是衬衫元素的属性的所有实例?

时间:2013-08-09 20:13:06

标签: xpath

如何编写一个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>

1 个答案:

答案 0 :(得分:2)

使用parent::Shirt nodetest,使用not取消谓词。

//@size[not(parent::Shirt)]