You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8 line
270B

  1. from typing import Optional
  2. from xml.etree import ElementTree
  3. def find_tag_text(parent: ElementTree.Element, tag: str, namespace: Optional[dict[str, str]] = None) -> str | None:
  4. elem = parent.find(tag, namespace)
  5. return elem.text if elem is not None else None