如何使用XQuery获得最高价格?我正在尝试学习XML和XQuery的基础知识,并提前感谢!
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications
with XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies,
an evil sorceress, and her own childhood to become queen
of the world.</description>
</book>
</catalogue>
答案 0 :(得分:2)
最高价格只是max(//price)
。如果您想要价格最高的图书,最简单的方法是//book[price=max(//price)]
,但这并不一定是最有效的(取决于您的优化工具)。