I am currently trying to extract all the text from one single XML element. This usually works, but I somehow don't get it to work when there is an additional element inside. Please see my minimal example:
xmlstring = """
<a>
<b> TEXT 1 <c> PHRASE </c> TEXT 2</b>
</a>
"""
parser = etree.XMLParser()
tree = etree.fromstring(xmlstring, parser)
What I tried is:
reslist = list(root.iter())
result = ' '.join([element.text for element in reslist])
The output is:
'\n\t TEXT 1 PHRASE '
The desired output would be:
'\n\t TEXT 1 PHRASE TEXT 2 '
tailproperty of thecelement.