Open this example in the interactive library
Source code
from xml.etree import ElementTree
root = ElementTree.fromstring('<book><title>Python</title></book>')
print(root.findtext('title'))Sample output
Python

Read an XML element. A self-contained example using the Python standard library.
Open this example in the interactive library
from xml.etree import ElementTree
root = ElementTree.fromstring('<book><title>Python</title></book>')
print(root.findtext('title'))Python