ElementTree -- adding one structure to another?

Jan Danielsson jan.m.danielsson at gmail.com
Wed Jun 27 07:48:32 CEST 2007


   If have an element tree representing an XML document, and I load
another tree from a file, is there an easy way to stick the second tree
into the first one?

   fooElement = ET.SubElement(...)

   tree = ET.parse(TEMPLDIR + '/welcome.xml')
   elem = tree.getroot()

   Now I want to stick elem as a subelement of fooElement. Do I need to
traverse the elem tree manually, or is there a way to just 'stick it in
there'?

-- 
Kind regards,
Jan Danielsson



More information about the Python-list mailing list