📅  最后修改于: 2022-03-11 14:45:45.926000             🧑  作者: Mango
import xml.etree.ElementTree as ET
context = ET.iterparse('file.xml', events=('start' , 'end' ))
for event, elem in context:
if elem.tag == 'row':
title = elem.find('NAME').text
filename = format(title + ".xml")
with open(filename, 'wb') as f:
f.write("\n")
f.write(ET.tostring(elem))