如何使用 XPath 查找一组元素中选择组的属性的 minimum/maximum 值?
How can I use XPath to find the minimum/maximum value of an attribute for chooses group in a set of elements?
<foo>
<bar id="1" score="100" group="beginner" />
<bar id="2" score="200" group="beginner" />
<bar id="3" score="300" group="expert" />
...
</foo>
我试过这样使用,但有些问题 (xpath 1.0)
foo/bar[@group='beginner' and not(@score<= preceding-sibling::bar/@score) and not(@score<=following-sibling::bar/@score)]
使用 xpath 1.0
/foo/bar[@group='beginner'][(not(preceding-sibling::bar[@group='beginner']/@score >= @score) and not(following-sibling::bar[@group='beginner']/@score > @score)) or (not(preceding-sibling::bar[@group='beginner']/@score <= @score) and not(following-sibling::bar[@group='beginner']/@score < @score))]/@score
<foo>
<bar id="1" score="100" group="beginner" />
<bar id="2" score="200" group="beginner" />
<bar id="3" score="300" group="expert" />
...
</foo>
我试过这样使用,但有些问题 (xpath 1.0)
foo/bar[@group='beginner' and not(@score<= preceding-sibling::bar/@score) and not(@score<=following-sibling::bar/@score)]
使用 xpath 1.0
/foo/bar[@group='beginner'][(not(preceding-sibling::bar[@group='beginner']/@score >= @score) and not(following-sibling::bar[@group='beginner']/@score > @score)) or (not(preceding-sibling::bar[@group='beginner']/@score <= @score) and not(following-sibling::bar[@group='beginner']/@score < @score))]/@score