fork download
  1. s = '''<tags>
  2. blabla<text>
  3. I want this
  4. </text>
  5. blabla<text>
  6. And this
  7. </text>
  8. bla<text>
  9. and this
  10. </text>blabla
  11. </tags>'''
  12.  
  13. import xml.etree.ElementTree as ET
  14. doc = ET.fromstring(s)
  15. print([el.text.strip() for el in doc.findall('.//text')])
  16.  
Success #stdin #stdout 0.05s 9912KB
stdin
Standard input is empty
stdout
['I want this', 'And this', 'and this']