[lxml-dev] Axis iteration

4 Jun
2006
4 Jun
'06
8:10 a.m.
Hi all,
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.
Stefan
6397
Age (days ago)
6397
Last active (days ago)
0 comments
1 participants
participants (1)
-
Stefan Behnel