Home > front end >  AttributeError: module 'xml.etree.ElementTree' has no attribute 'ElimentTree'
AttributeError: module 'xml.etree.ElementTree' has no attribute 'ElimentTree'

Time:11-28

I am trying to delete an element from xml document but I am getting error :

Traceback (most recent call last):
  File "C:/Ashok/del_element_tree_country_2.py", line 25, in <module>
    tree = ET.ElimentTree(root)
AttributeError: module 'xml.etree.ElementTree' has no attribute 'ElimentTree'

My code is:

import xml.etree.ElementTree as ET

tree = ET.ElementTree(file='C:\\Ashok\\sample.xml')

root = tree.getroot()

DisabledFeatureListForCountry = root.find('.//DisabledFeatureListForCountry')

for DisabledFeatureDetails in DisabledFeatureListForCountry.findall('DisabledFeatureDetails'):
    _id = DisabledFeatureDetails.find('Country')
    if (_id.text == "Australia"):
        DisabledFeatureListForCountry.remove(DisabledFeatureDetails)

tree = ET.ElimentTree(root)

with open(filename, "wb") as fileupdate:
    trre.write(fileupdate)

Thanks in advance

CodePudding user response:

Your error comes from this line:

tree = ET.ElimentTree(root)

Replace it by the following line:

tree = ET.ElementTree(root)
  • Related