with codecs.open('test.xml', 'r', 'utf-8') as inp:
    xml = minidom.parseString(inp.read().encode('utf-8'))
with codecs.open('out.xml', 'w', 'utf-8') as out:
    pass
Writing XML to file corrupts files in python