Yes, this will also work. In you original XPath expression I missed the fact that you start from '/' , not '//' so you don't need to worry about the "start from root" fact. Aleksey > <XPath xmlns:ns="urn:namespace"> ancestor-or-self::ns:Root and > ancestor-or-self::ns:FirstChild </XPath>