ElementTree.SubElement(tree, 'body')
with open('myfile.tmx', 'w') as f:
    f.write(
        '<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE tmx SYSTEM "tmx14a.dtd">'
        )
Как создать <!DOCTYPE> с Python ElementTree