Hi,
I'm struggling with a weird problem with saving xml a file.
I tested this in a pc and the file is created with the xml.
In pythonista the file is created but it is empty.
What might be the problem?
Here is the simple code:
#coding: utf-8
#!python2
import xml.etree.ElementTree as et
substring_xml_file = u"Category_Substring_test.xml"
cat = "Compras"
descricao_str_r = "Supermercado"
root = et.Element("root")
a = et.SubElement(root, u"CategoryEntry")
a.set(u"Category", cat)
a.set(u"Payee", " ")
a.set(u"SubString", descricao_str_r)
f = open(substring_xml_file, "w")
tree = et.ElementTree(root)
tree.write(f, encoding=u"UTF-8", xml_declaration=True)
#Category_Substring_test.xml content should be:
'''
<?xml version='1.0' encoding='UTF-8'?>
<root><CategoryEntry Category="Compras" Payee=" " SubString="Supermercado" /></root>
'''