at the risk of screaming at asking such a simple question, but Iβm baiting the Internet for answers, and this particular case seems to be widely avoided, and the documents are ambiguous:
Is it possible to use xml.etree.ElementTree.write () to write non-string values ββin an element attribute? I always get:
TypeError: cannot serialize 0 (type int)
when I try something like this:
root = ET.Element('Tasks') d = {'priority': 1, 'status': 0, 'name': 'new task', 'index': 0} d = ET.SubElement(root, 'Settings', attrib=d) tree = ET.ElementTree(root) tree.write('/tmp/xmlTest')
I worked on it several times, iterating over the corresponding dictionary and first turning all the values ββinto strings, but this does not seem to be correct, and before I process it again, I would like to know how it should be done correctly so as not to get used to the bad habit. So any insight would be greatly appreciated.
Cheers frank
source share