[lxml-dev] Reparenting a node

Stefan Behnel stefan_ml at behnel.de
Sun Sep 9 19:57:12 CEST 2007


Lawrence Oluyede wrote:
> I have a doc A and a doc B, I'd like to put a node extracted from A in
> the document B but I always get a ValueError:
> 
> ValueError: Element is not a child of this node.

Sounds like you're using remove() or index(), no need to do that.


> I didn't find any "setparent" in the API.
> 
> How can I do this?

try

node_in_B.append(node_in_A)

See the "Elements are lists" section in the tutorial.

Stefan


More information about the lxml-dev mailing list