ElementTree insert element from another file and save



I need to a section of File1.XML to File2.XML...Below script printing the desired but only for element.How can this update be saved in File2.XML?



from xml.etree import ElementTree as et

tree1 = xml.etree.ElementTree.parse('File1.xml')
root1 = tree1.getroot()

tree2 = xml.etree.ElementTree.parse('File2.xml')
root2 = tree2.getroot()

root2.insert(0,root1)
print et.tostring(root2)

No comments:

Post a Comment