title: Remove whitespaces in XML string
body: <p>How can I remove the whitespaces and line breaks in an XML string in Python 2.6? I tried the following packages:</p>
  
  <p>etree: This snippet keeps the original whitespaces:</p>
  
  <pre><code>xmlStr = '''&lt;root&gt;
      &lt;head&gt;&lt;/head&gt;
      &lt;content&gt;&lt;/content&gt;
  &lt;/root&gt;'''
  
  xmlElement = xml.etree.ElementTree.XML(xmlStr)
  xmlStr = xml.etree.ElementTree.tostring(xmlElement, 'UTF-8')
  print xmlStr
  </code></pre>
  
  <p>I can not use Python 2.7 which would provide the <code>method</code> parameter.</p>
  
  <p>minidom: just the same:</p>
  
  <pre><code>xmlDocument = xml.dom.minidom.parseString(xmlStr)
  xmlStr = xmlDocument.toprettyxml(indent='', newl='', encoding='UTF-8')
  </code></pre>