do not collapse empty nodes in XML output
问题 I'm using python's xml.etree.ElementTree to represent an XML document. I want to output it to text but I want to keep empty elements (elements with no children) expanded, instead of collapsed. E.g., I want this: <element></element> Instead of this: <element /> I'm currently using ElementTree.tostring , but I'm willing to use any other built-in python modules or functions to serialize the document, as long as I can pretty easily use an ElementTree object with it. FYI, the reason I want to keep