DOM appendChild??

Andrew Clover and-google at
Tue Nov 2 00:05:27 CET 2004

Juliano Freitas <jubafre at> wrote:

> I have to append in a xml file as a child another xml file. How can i
> get this?

> i try parent.appendChild(document)

A node from one document can't directly be inserted into another. You
need to call Document.importNode first. Also you can't put the
Document node directly into a parent, because it is by definition the
root object of the entire DOM tree. What you probably want to do is
insert the root element node, which you can read with

  el= parent.ownerDocument.importNode(document.documentElement, True)

Andrew Clover
mailto:and at

More information about the Python-list mailing list