OK. I see..
Polat Tuzla, 09.11.2009 15:17:
> Thank you for your response.An XPath query will not construct a new tree for you. What you see here is
> I looked at the other results, and they did not seem to obey the xpath axis
> either.
> By using ancestor-or-self, I'm expecting an output like this:
>
> <a>
> <b>
> <c/>
> </b>
> </a>
>
>
> But the other results that are returned to me are:
>
> In [311]: print etree.tostring(root.xpath("/a/b/c/ancestor-or-self::*")[1],
> pretty_print=True)
> .....:
> <b>
> <c/>
> <x>
> <z/>
> </x>
> </b>
the result of serialising the second node in the result set, including its
subtree *as defined in the document*. This has nothing to do with the query
you ran *before* the serialisation, and which correctly returned the
matching nodes in a list.
Stefan