From b1bd134eb44fbad90c2967eedeeb3d59974a319d Mon Sep 17 00:00:00 2001 From: "sgunderson@bigfoot.com" <> Date: Wed, 6 Sep 2006 17:48:41 +0200 Subject: [PATCH] Fix much of the cloning. --- python/xmltemplate.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/python/xmltemplate.py b/python/xmltemplate.py index cac93b7..edffea7 100644 --- a/python/xmltemplate.py +++ b/python/xmltemplate.py @@ -50,11 +50,10 @@ def process(node, obj, clean = True): doc = _get_document_element(node) frag = doc.createElement("temporary-fragment") # ugh - for child in node.childNodes: - frag.appendChild(child) - - for child in node.childNodes: + while not node.firstChild is None: + child = node.firstChild node.removeChild(child) + frag.appendChild(child) for instance in obj: newnode = frag.cloneNode(True) @@ -65,11 +64,17 @@ def process(node, obj, clean = True): # remove all the tags + children_to_remove = [] for child in node.childNodes: if isinstance(child, xml.dom.minidom.Element) and child.tagName == 'temporary-fragment': - for child2 in child.childNodes: + while not child.firstChild is None: + child2 = child.firstChild + child.removeChild(child2) node.appendChild(child2) - node.removeChild(child) + children_to_remove.append(child) + + for child in children_to_remove: + node.removeChild(child) if clean: _clean(node) -- 2.39.2