How can I get all the text content of an XML document, as a single string - like this Ruby/hpricot example but using Python.
I'd like to replace XML tags with a single whitespace.
Using stdlib xml.etree
xml.etree
import xml.etree.ElementTree as ET tree = ET.parse('sample.xml') print(ET.tostring(tree.getroot(), encoding='utf-8', method='text'))
2.1m questions
2.1m answers
60 comments
57.0k users