Jos Vos wrote:
> What is the recommended way (in the libxml2 Python binding) to copy
> a node and all of its children (but not its siblings!) from one
> document to another document?

;) the recommended way to use libxml2 from Python is lxml.


> I tried (x is a node in the new document, y a node in the old document):
>       
>       x.addChild(y)
>       x.addChild(y.copyNodeList())

Ok, you want to copy, not move the node, so lxml.etree would do:

   >>> from copy import deepcopy
   >>> x.append(deepcopy(y))

Short and intuitive.

Stefan

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to