title: Unicode error when passing unicode object to XML parser
body: <p>I am trying to read a gzip file which contains xml and unicode, but I'm getting an error. The code I am using is:</p>
  
  <pre><code>import gzip
  import xml
  
  path = "index.mjml.gz"
  gzFile = gzip.open(path, mode='r')
  gzContents = gzFile.read()
  gzFile.close()
  
  unicodeContents = gzContents.encode('utf-8')
  xmlContent = xml.dom.minidom.parseString(unicodeContents)
  # Do stuff with xmlContent
  </code></pre>
  
  <p>When I run this code I get the following error (fails on the line that starts with <code>xmlContent</code>)</p>
  
  <pre><code>/Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/xml/dom/minidom.pyc in parseString(string, parser)
     1922     if parser is None:
     1923         from xml.dom import expatbuilder
  -&gt; 1924         return expatbuilder.parseString(string)
     1925     else:
     1926         from xml.dom import pulldom
  
  /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/xml/dom/expatbuilder.pyc in parseString(string, namespaces)
      938     else:
      939         builder = ExpatBuilder()
  --&gt; 940     return builder.parseString(string)
      941 
      942 
  
  /Library/Frameworks/EPD64.framework/Versions/7.1/lib/python2.7/xml/dom/expatbuilder.pyc in parseString(self, string)
      221         parser = self.getParser()
      222         try:
  --&gt; 223             parser.Parse(string, True)
      224             self._setup_subset(string)
      225         except ParseEscape:
  
  UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1141336: ordinal not in range(128)
  </code></pre>
  
  <p>I found a previous answer similar to this <a href="https://stackoverflow.com/questions/1883604/reading-utf-8-characters-from-a-gzip-file-in-python">Reading utf-8 characters from a gzip file in python</a>, but I'm still getting an error.</p>
  
  <p>Is there a problem with the xml parser?</p>
  
  <p>(I'm using Python 2.7.?)</p>