Hi--
I've been using $foo->paste('last_child', $bar) to graft subtrees onto a larger tree and it's been working as expected. That is, the paste will *copy* the contents of foo onto bar.
Now, it seems that the paste is using a pointer of foo to the bar tree. Since foo is populated within a loop with a "new" for foo at the start of the iteration, each time the new is hit, the contents of the prior foo (now attached to bar) vanishes. What persists on bar is only the value of foo.
Strangely, the population of the nodes within foo is done via the same paste/last-child mechanism, but this works as expected.
Can someone clarify this? Or am I doing something wrong? Thanks.
use XML::Twig; my $objectsTwig = new XML::Twig; $objectsTwig->parse('<objects />'); $OBJECTS_ROOT = $objectsTwig->root; do { my $object = new XML::Twig; $object->parse('<object />'); $OBJECT_ROOT = $object->root; ... Add elements to <object> node $OBJECT_ROOT->paste('last_child', $OBJECTS_ROOT); } until (yada...);
In reply to XML-Twig paste by zuma53
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |