I`m editing a XML file with Python xml.etree.ElementTree. Here is simple file example:
<root>
<sub1>1</sub1>
<sub2>2</sub2>
</root>
And I want to remove all root subelements. When I use
...
for child in root:
root.remove(child)
...
'remove' method deletes only first subelement. But with
...
for child in root.getchildren():
root.remove(child)
...
it works with all subelements. Why is this happening? Is it some iterator feature, or I need to know more about 'remove' method?