使用方法见:https://www.cnblogs.com/Zhouzg-2018/p/9926048.html
from xml.dom.minidom import Document
import xml.etree.ElementTree as ET
#
# def writeXml(imgPath='',save_path="/home/gui/newXml.xml"):
#
# #先简单实现下,考虑一个目标
# doc=Document()
# root=doc.createElement('annotation')
# doc.appendChild(root)
#
# node_1=doc.createElement('folder')
# txt_1=doc.createTextNode('ImageSets')
# node_1.appendChild(txt_1)
# root.appendChild(node_1)
#
# node_2=doc.createElement('name')
# txt_2=doc.createTextNode('0001.jpg')
# node_2.appendChild(txt_2)
# root.appendChild(node_2)
#
# node_3=doc.createElement('path')
# txt_3=doc.createTextNode('/home/gui/mot2015/0001.jpg')
# node_3.appendChild(txt_3)
# root.appendChild(node_3)
#
# node_4=doc.createElement('size')
# node_41=doc.createElement('width')
# txt_41=doc.createTextNode('100')
# node_41.appendChild(txt_41)
# node_42=doc.createElement('height')
# txt_42=doc.createTextNode('100')
# node_42.appendChild(txt_42)
# node_4.appendChild(node_41)
# node_4.appendChild(node_42)
# root.appendChild(node_4)
#
# node_object=doc.createElement('object')
# node_5=doc.createElement('Xmin')
# txt_5=doc.createTextNode('1')
# node_5.appendChild(txt_5)
# node_object.appendChild(node_5)
# node_6=doc.createElement('Ymin')
# txt_6=doc.createTextNode('1')
# node_6.appendChild(txt_6)
# node_object.appendChild(node_6)
# node_7=doc.createElement('Xmax')
# txt_7=doc.createTextNode('1')
# node_7.appendChild(txt_7)
# node_object.appendChild(node_7)
# node_8=doc.createElement('Ymax')
# txt_8=doc.createTextNode('1')
# node_8.appendChild(txt_8)
# node_object.appendChild(node_8)
# root.appendChild(node_object)
#
# with open(save_path,'w')as outFile:
# doc.writexml(outFile,indent='\t', newl='\n', addindent='\t', encoding='gbk')
#
# outFile.close()
#
# writeXml()
def generate(xmlFile=""):
root