Can't dump or write an ElementTree element

SubElement does not take an element as the second parameter. The API docs give the signature as

SubElement(parent, tag, attrib={}, **extra)

i.e. the second parameter is the tag (i.e. name) of the sub element

The ElementTree docs give more detail

To add a child element look at the append method on Element e.g.

root.append(child)

http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.SubElement

SubElement's second argument is tag (str) not Element, it creates Element instance by itself:

>>> SubElement(root, 'child')
0: <Element 'child' at 0x1f2dfb0>
>>> tostring(root)
1: '<parent><child /></parent>'