Copying Elements using PyXML

Pat Notz pknotz at sandia.gov
Tue Sep 24 21:27:53 CEST 2002


This is an untested snippet of code that should get you started.  It
looks like you'll want to do you .appendChild on a node other than
.documentElement...

# Merge subsequet DOMs
dom = None
for xmlfile in xmlfiles:
    tmp_dom = xml.dom.minidom.parse(xmlfile)
    if dom == None:
        dom = tmp_dom
    else:
        for node in tmp_dom.documentElement.childNodes:
            e = dom.importNode(node,True)
            dom.documentElement.appendChild(e)



More information about the Python-list mailing list