1import xml.etree.ElementTree as ET
2context = ET.iterparse('file.xml', events=('start' , 'end' ))
3for event, elem in context:
4 if elem.tag == 'row':
5 title = elem.find('NAME').text
6 filename = format(title + ".xml")
7 with open(filename, 'wb') as f:
8 f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
9 f.write(ET.tostring(elem))
10