def createSubElement(text, tagText=''):
    elem = etree.SubElement(root, text)
elem.text = tagText
createSubElement('firstChild', 'first one')
createSubElement('SecondChild', 'second one')
print(etree.tostring(root))
Confused as to use a class or a function: Writing XML files using lxml and Python