ElementTree -- adding one structure to another?
jan.m.danielsson at gmail.com
Wed Jun 27 07:50:08 CEST 2007
Jan Danielsson wrote:
> 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
Found it two seconds after sending the post. fooElement.append().
More information about the Python-list