0

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

1 回答 1

2

使用parent::轴,Shirtnodetest,否定谓词not

//@size[not(parent::Shirt)]
于 2013-08-09T20:20:19.777 回答