Getting element’s name in XPATH

Use name(). (Find docs for newer versions of the XPath language here.) Here are modified versions of your example: Works in XPath 2.0+ only: //element/*[@id=’elid’]/name() Works in XPath 1.0 and 2.0+*: name(//element/*[@id=’elid’]) *If using 2.0+, the expression //element/*[@id=’elid’] must only return one element. Otherwise you’ll get an error like A sequence of more than one … Read more