[lxml-dev] Axis iteration
4 Jun 2006 4 Jun '06
I thought a bit more about the axis issues that Andrey raised. While list-like access to them is not a viable solution IMHO (and already covered by XPath calls anyway), I think it would still be nice to provide them as iterators.
I therefore added a few new methods to Element:
itersiblings(preceding=False) iterancestors() iterdescendants()
Note that iterdescendants() is almost like getiterator(), except that it does not include the element itself, which is consistent with XPath's descendant axis. getiterator() is therefore the equivalent of the descendant-or-self axis.
I think these methods are pretty Pythonic and make tree navigation fairly simple.
Age (days ago)
Last active (days ago)