XPath to get the maximum ID

后端 未结 3 557
遥遥无期
遥遥无期 2021-01-06 20:18

XML Source:


    
        School A
        
            Student A         


        
3条回答
  •  情书的邮戳
    2021-01-06 20:38

    Just for completeness... If you could had XPath 2.0 available, you could use max(), as in:

    /*/school[*/id = max(//id)]/name
    

    It's a little easier than in XPath 1.0.

    However AFAIK you do not have XPath 2.0 available in Python. So go with @cdhowie's or @Alejandro's answer.

提交回复
热议问题