Create tree iterator. The iterator loops over the element and all subelements in document order, returning all elements with a matching tag. If the tree structure is modified during iteration, new or removed elements may or may not be included. To get a stable set,
(self, tag=None)
| 375 | return self.attrib.items() |
| 376 | |
| 377 | def iter(self, tag=None): |
| 378 | """Create tree iterator. |
| 379 | |
| 380 | The iterator loops over the element and all subelements in document |
| 381 | order, returning all elements with a matching tag. |
| 382 | |
| 383 | If the tree structure is modified during iteration, new or removed |
| 384 | elements may or may not be included. To get a stable set, use the |
| 385 | list() function on the iterator, and loop over the resulting list. |
| 386 | |
| 387 | *tag* is what tags to look for (default is to return all elements) |
| 388 | |
| 389 | Return an iterator containing all the matching elements. |
| 390 | |
| 391 | """ |
| 392 | if tag == "*": |
| 393 | tag = None |
| 394 | if tag is None or self.tag == tag: |
| 395 | yield self |
| 396 | for e in self._children: |
| 397 | yield from e.iter(tag) |
| 398 | |
| 399 | def itertext(self): |
| 400 | """Create text iterator. |
no outgoing calls