I have code like this for removing all tags named sysId from xml in root_compare function:
#removing sysId from comparison
for rm1 in xml_root1.findall('.//sysId'):
xml_root1.remove(rm1)
The code gives me this error:
File "/tmp/dev_uac_api2/uac_api_lib.py", line 105, in root_compare
xml_root1.remove(rm1)
File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 337, in remove
self._children.remove(element)
ValueError: list.remove(x): x not in list
I need to go through all elements in xml even child, grandchild and remove the ones called sysId. Can you help me solve this problem?
the xml structure is something like:
<root>
<sysId></sysId>
<b></b>
<c>
<sysId></sysId>
</c>
<d>
<e>
<sysId></sysId>
</e>
</d>
</root>