Skip to content Skip to sidebar Skip to footer

Python Xml.etree - Remove Node But Keep Children (assign Children To Grandparents)

In Python, how do I remove a node but keep its children using xml.etree API? Yes I know there's an answer using lxml but since xml.etree is part of Python website, I figure it dese

Solution 1:

Remove this line from your program:

        country.remove(country_child)

The iteration of an xml.etree.ElementTree.Element is essentially passed through to the list of sub-elements. Modifying that list during iteration will yield odd results.

Post a Comment for "Python Xml.etree - Remove Node But Keep Children (assign Children To Grandparents)"