DOM appendChild??

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


Juliano Freitas <jubafre at atlas.ucpel.tche.br> 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
Document.documentElement:

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

-- 
Andrew Clover
mailto:and at doxdesk.com
http://www.doxdesk.com/



More information about the Python-list mailing list