Package lxml :: Module etree :: Class ElementDepthFirstIterator
[hide private]
[frames] | no frames]

Class ElementDepthFirstIterator

object --+

ElementDepthFirstIterator(self, node, tag=None, inclusive=True) Iterates over an element and its sub-elements in document order (depth first pre-order).

Note that this also includes comments, entities and processing instructions. To filter them out, check if the tag property of the returned element is a string (i.e. not None and not a factory function), or pass the Element factory for the tag argument to receive only Elements.

If the optional tag argument is not None, the iterator returns only the elements that match the respective name and namespace.

The optional boolean argument 'inclusive' defaults to True and can be set to False to exclude the start element itself.

Note that the behaviour of this iterator is completely undefined if the tree it traverses is modified during iteration.

Instance Methods [hide private]
a new object with type S, a subtype of T
__new__(T, S, ...)
the next value, or raise StopIteration

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__new__(T, S, ...)

Returns: a new object with type S, a subtype of T
Overrides: object.__new__