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'))
1.4m articles
1.4m replys
5 comments
57.0k users