title: How to correctly parse utf-8 xml with ElementTree?
body: <p>I need help to understand why parsing my xml file* with <strong>xml.etree.ElementTree</strong> produces the following errors. </p>
  
  <p>*<em>My test xml file contains arabic characters.</em> </p>
  
  <p><strong>Task:</strong>
  Open and parse <code>utf8_file.xml</code> file.</p>
  
  <p><strong>My first try:</strong></p>
  
  <pre><code>import xml.etree.ElementTree as etree
  with codecs.open('utf8_file.xml', 'r', encoding='utf-8') as utf8_file:
      xml_tree = etree.parse(utf8_file)
  </code></pre>
  
  <p><strong>Result 1:</strong></p>
  
  <pre><code>UnicodeEncodeError: 'ascii' codec can't encode characters in position 236-238: ordinal not in range(128)
  </code></pre>
  
  <p><strong>My second try:</strong></p>
  
  <pre><code>import xml.etree.ElementTree as etree
  with codecs.open('utf8_file.xml', 'r', encoding='utf-8') as utf8_file:
      xml_string = etree.tostring(utf8_file, encoding='utf-8', method='xml')
      xml_tree  = etree.fromstring(xml_string)
  </code></pre>
  
  <p><strong>Result 2:</strong></p>
  
  <pre><code>AttributeError: 'file' object has no attribute 'getiterator'
  </code></pre>
  
  <p>Please explain the errors above and comment on the possible solution.</p>