And here you could use XPathResult.FIRST_ORDERED_NODE_TYPE instead of "9"