Hi all,
I looked for clone element function but not found such tool:
def CloneElment(fromElem, destRoot = None)
fromElem is the element to clone
destRoot is the container of the new element ;if None so the new element will be contained by the fromElem container
here is a first implementation:
def CloneElement(fromElem, destRoot = None):
fromRoot = ET.ElementTree(fromElem).getroot()
if destRoot == None:
destRoot = fromRoot
destElem = destRoot.makeelement(fromElem.tag, fromElem.attrib)
destRoot.append(destElem)
destElem.text = fromElem.text
for e in fromElem.findall('*'):
CloneElement(e, destElem)
#
Hi all,
I looked for clone element function but not found such tool:
def CloneElment(fromElem, destRoot = None)
fromElem is the element to clone
destRoot is the container of the new element ;if None so the new element will be contained by the fromElem container
here is a first implementation:
Thanks for any advice.