ET.register_namespace('com', 'http://www.company.com')
root = ET.Element('{http://www.company.com}STUFF')
body = ET.SubElement(root, '{http://www.company.com}MORE_STUFF')
body.text = 'STUFF EVERYWHERE!'
tree = ET.ElementTree(root)
tree.write('page.xml', xml_declaration=True, encoding='utf-8', method='xml')
Выдача спецификаций пространства имен с помощью ElementTree в Python