How to find the max attribute from an XML document using Xpath 1.0

后端 未结 7 1051
无人及你
无人及你 2020-11-29 10:43

Is there a way to query an XML document to return the maximum of a given attribute using Xpath 1.0 ?

For example is there a way to get the max id ?

&         


        
7条回答
  •  隐瞒了意图╮
    2020-11-29 10:58

    In XPath 2.0, use the max function. To find the book with the highest id, do

    /library/book[@id = max(/library/book/@id)]
    

提交回复
热议问题