Very new to XML and Python. I want to change the tag names of certain elements in an XML document. Here\'s how the document looks now:
<
If you want to use ElementTree, you can find all SSN
elements that are children of Employee
and set tag
.
Example...
Input (input.xml)
111111111
222222222
Python
import xml.etree.ElementTree as ET
tree = ET.parse("input.xml")
for elem in tree.findall("Employee/SSN"):
elem.tag = "EESSN"
tree.write("output.xml")
Output (output.xml)
111111111
222222222