Element.findtext()
Element.findtext() is a Python method in the XML Module category. Finds text of the first matching child element. The syntax is element.findtext(match, default=None, namespaces=None). Returns: Text string or default. A typical example: text = root.findtext("title", default=""). A close sibling is xml.etree.ElementTree.parse(), which parses an XML file and returns an ElementTree object. A close sibling is xml.etree.ElementTree.fromstring(), which parses XML from a string and returns an Element. A close sibling is xml.etree.ElementTree.tostring(), which serializes an Element to bytes (XML string). A close sibling is xml.etree.ElementTree.Element(), which creates a new XML element with the given tag and attributes. More about this category: XML processing — ElementTree, parse, fromstring, tostring. Related XML Module entries: xml.etree.ElementTree.parse(), xml.etree.ElementTree.fromstring(), xml.etree.ElementTree.tostring(), xml.etree.ElementTree.Element(), xml.etree.ElementTree.SubElement(), Element.find(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try Element.findtext() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.