How can I remove the whitespaces and line breaks in an XML string in Python 2.6? I tried the following packages:
etree: This snippet keeps the original whitespaces:<
xmlStr = xmlDocument.toprettyxml(indent='\t', newl='\n', encoding='UTF-8') fix = re.compile(r'((?<=>)(\n[\t]*)(?=[^<\t]))|(?<=[^>\t])(\n[\t]*)(?=<)') newXmlStr = re.sub(fix, '', xmlStr )
from this source