pythonxml.etree

etree Clone Node


How to clone Element objects in Python xml.etree? I'm trying to procedurally move and copy (then modify their attributes) nodes.


Solution

  • You can just use copy.deepcopy() to make a copy of the element. (this will also work with lxml by the way).