I read the tree from the file as a string and removed namespaces from it.
with open(pathArxmlFileName, 'r') as myfile:
data=myfile.read();
data = re.sub(' xmlns="[^"]+"', '', data, count=1)
self.root = ET.fromstring(data);
self.tree = ET.ElementTree(self.root)
I want to remove an XML element from this tree
I tried:
for EL in self.root.iter('tagString'):
self.root.remove(EL);
Find EL elements, but when I call the remove () function, it throws an error:
self._children.remove(element)
ValueError: list.remove(x): x not in list
Please help me, I do not know what to do: (
Ps: Modifying a tree by changing the value of an element works
source
share