En Mon, 02 Feb 2009 12:37:36 -0200, Gerard Flanagan <grflana...@gmail.com> escribió:

e = ET.fromstring(s)

def clone(elem):
     ret = elem.makeelement(elem.tag, elem.attrib)
     ret.text = elem.text
     for child in elem:
         ret.append(clone(child))
     return ret

f = clone(e)

You forget the tail attribute, and you also should use the SubElement factory instead of makeelement as documented; doing that fixes the "parent" issue too.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to