Find first matching element by tag name or path. Same as getroot().find(path), which is Element.find() *path* is a string having either an element tag or an XPath, *namespaces* is an optional mapping from namespace prefix to full name. Return the first matching ele
(self, path, namespaces=None)
| 597 | return self._root.iter(tag) |
| 598 | |
| 599 | def find(self, path, namespaces=None): |
| 600 | """Find first matching element by tag name or path. |
| 601 | |
| 602 | Same as getroot().find(path), which is Element.find() |
| 603 | |
| 604 | *path* is a string having either an element tag or an XPath, |
| 605 | *namespaces* is an optional mapping from namespace prefix to full name. |
| 606 | |
| 607 | Return the first matching element, or None if no element was found. |
| 608 | |
| 609 | """ |
| 610 | # assert self._root is not None |
| 611 | if path[:1] == "/": |
| 612 | path = "." + path |
| 613 | warnings.warn( |
| 614 | "This search is broken in 1.3 and earlier, and will be " |
| 615 | "fixed in a future version. If you rely on the current " |
| 616 | "behaviour, change it to %r" % path, |
| 617 | FutureWarning, stacklevel=2 |
| 618 | ) |
| 619 | return self._root.find(path, namespaces) |
| 620 | |
| 621 | def findtext(self, path, default=None, namespaces=None): |
| 622 | """Find first matching element by tag name or path. |