//a[@x='1' and position()=last()]
<r><a x='1'/><a x='2'/></r>