Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

given this code snippet:
foreach my $child ($tag->children) { my $newElt= XML::Twig::Elt->new(Contains => { map {$_ , $child->{'at +t'}->{$_}||''} qw(name type comment) }); $tag->paste('last_child', $newElt); }
how can it be that the program dies with:
cannot paste an element that belongs to a tree at ./E2W line 546
line 546 is the past-line.

Replies are listed 'Best First'.
Re: XML::Twig::Elt cannot paste. Why?
by Skeeve (Parson) on Oct 21, 2003 at 10:55 UTC
    I found my mistake...
    it should be:
    $newElt->paste('last_child', $tag);
    not
    $tag->paste('last_child', $newElt);
    Sorry...