I'm trying to retrieve the last and second to last entries for the date element in the below example:
<c:classroom>Classroom 1</c:classroom>
<a:date>2018-03-01</a:date>
<a:teacher>Ms Smith</a:teacher>
<a:assistant>Sara</a:assistant>
<a:student>Rose</a:student>
<a:student>Kris</a:student>
<a:student>Jane</a:student>
<c:classroom>Classroom 2</c:classroom>
<a:date>2018-03-02</a:date>
<a:teacher>Mr Jones</a:teacher>
<a:assistant>Bob</a:assistant>
<a:student>Mike</a:student>
<a:student>Pat</a:student>
<a:student>Rick</a:student>
<c:classroom>Classroom 1</c:classroom>
<a:date>2018-03-05</a:date>
<a:teacher>Ms Smith</a:teacher>
<a:assistant>Sara</a:assistant>
<a:student>Rose</a:student>
<a:student>Kris</a:student>
<a:student>Jane</a:student>
<c:classroom>Classroom 2</c:classroom>
<a:date>2018-03-06</a:date>
<a:teacher>Mr Jones</a:teacher>
<a:assistant>Bob</a:assistant>
<a:student>Mike</a:student>
<a:student>Pat</a:student>
<a:student>Rick</a:student>
Using //*[local-name() = 'date'][last()] returns almost everything and using //*[local-name() = 'date'][last()-1] fails.
Any suggestions?
UPDATE: This XPath query is for use in Google Sheets.
last()andposition()operators as @zx485 used. Happy though to delete if SE still concludes it's a duplicate or doesn't contribute enough to stand alone.