By unwinding xml.dom.minidom and searching for "/"> ", we will find this:
def writexml(self, writer, indent="", addindent="", newl=""):
if self.childNodes:
writer.write(">%s"%(newl))
for node in self.childNodes:
node.writexml(writer,indent+addindent,addindent,newl)
writer.write("%s</%s>%s" % (indent,self.tagName,newl))
else:
writer.write("/>%s"%(newl))
From this we can conclude that the short-end-tag form occurs only when childNodes is an empty list. Indeed, it looks like this:
>>> doc = Document()
>>> v = doc.appendChild(doc.createElement('v'))
>>> v.toxml()
'<v/>'
>>> v.childNodes
[]
>>> v.appendChild(doc.createTextNode(''))
<DOM Text node "''">
>>> v.childNodes
[<DOM Text node "''">]
>>> v.toxml()
'<v></v>'
, XML . , , , .
xml.dom.minidom - -, . . Element toxml, , . monkeypatch , Element.