I am trying to output an XML file using Python and lxml
However, I notice one thing: if the tag has no text, it does not close. An example of this might be:
root = etree.Element('document') rootTree = etree.ElementTree(root) firstChild = etree.SubElement(root, 'test')
The result of this:
<document> <test/> </document
I want the output to be:
<document> <test> </test> </document>
So basically I want to close a tag that has no text but is used for the attribute value. How can I do it? And also, what is such a tag called? I would googled, but I donβt know how to look for it.
source share