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.
What about:
//student[not(../../school/student/id > id)]
Or, more simply:
//student[not(//student/id > id)]
To get the <school/>
element with the highest student ID, I believe this will work:
//school[student[not(//student/id > id)]]
Use:
/schools/school[student[not(../../school/student/id > id)]]/name
Or shorter (just for this schema):
/*/school[*/id[not(//id > .)]]/name