from lxml import etree
 
root = etree.Element("root")
root.tag # Tag name is here
 
# Add subelements to the root, more common way
child = etree.SubElement(root, "name-of-child")
# This could also be done like below but it's discouraged
root = root.append(etree.Element("child"))
 
# Show me the XML tree
print(etree.tostring(root, pretty_print=True))
 
# Elements are lists
child = root[0] # <Element name-of-child>
root.index(root[0])
 
for child in root:
	print(child.tag)
 
root.insert(0, etree.Element("child0"))
start = root[:1] # start[0].tag
end   = root[-1:] # end[0].tag
 
etree.iselement(root) # Is XML tree?
if len(root): print("Has children!")

Examples are taken from this tutorial: https://lxml.de/tutorial.html (Status: 2022-08-20)