It would be great if you could share the file Here's one of my suggestions on how you can do it
import xml.etree.ElementTree as ET
tree = ET.parse('file.xml')
root = tree.getroot()
# Find all headers by their tag name
headers = root.findall('.//header1') # Use './/' to find all occurrences
for header in headers[1:]:
root.remove(header)
I'm not sure of my proposed solution, so please correct me if you need to. Thanks