Find first matching element by tag name or path. Same as getroot().findtext(path), which is Element.findtext() *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 mat
(self, path, default=None, namespaces=None)
| 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. |
| 623 | |
| 624 | Same as getroot().findtext(path), which is Element.findtext() |
| 625 | |
| 626 | *path* is a string having either an element tag or an XPath, |
| 627 | *namespaces* is an optional mapping from namespace prefix to full name. |
| 628 | |
| 629 | Return the first matching element, or None if no element was found. |
| 630 | |
| 631 | """ |
| 632 | # assert self._root is not None |
| 633 | if path[:1] == "/": |
| 634 | path = "." + path |
| 635 | warnings.warn( |
| 636 | "This search is broken in 1.3 and earlier, and will be " |
| 637 | "fixed in a future version. If you rely on the current " |
| 638 | "behaviour, change it to %r" % path, |
| 639 | FutureWarning, stacklevel=2 |
| 640 | ) |
| 641 | return self._root.findtext(path, default, namespaces) |
| 642 | |
| 643 | def findall(self, path, namespaces=None): |
| 644 | """Find all matching subelements by tag name or path. |