SyntaxFix
Write A Post
Hire A Developer
Questions
You need to put the last() indexing on the nodelist result, rather than as part of the selection criteria. Try:
last()
(//element[@name='D'])[last()]