item.append(field)
return item
root = et.Element('AllItems')
tree = et.ElementTree(root)
root.append(dict_to_elem({'some_tag': 'Hello World', 'xxx': 'yyy'}))
filename = 'a.xml'
with open(filename, 'w', encoding='utf-8') as file:
    tree.write(file, encoding='unicode')
fname = 'b.xml'
with open(fname, 'wb') as f:
    tree.write(f, encoding='utf-8')
Создание Unicode XML с нуля с помощью Python 3.2