import xml.etree.ElementTree as etree import copy def main(i): tree = etree.parse('test_project_write.xml') root = tree.getroot() Project = root.find('Projects/Project') Project.attrib['projectID'] = 'Нагрузочное' + str(i) Blines = Project.find('ProjectBaselines') baseline = Blines.find('ProjectBaseline') for j in range(2, 51): #creating new new_baseline = copy.deepcopy(baseline) new_baseline.attrib['revisionID'] = str(j) new_baseline.attrib['name'] = str(j) Blines.append(new_baseline) tree.write('out2.xml', 'UTF-8') if __name__ == "__main__": main(2)