Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Monks i need to cut a element with children and paste in another location. I tried using XML::Twig. But i could not able to get correct output. I have shown below what i tried and sample example. where am i going wrong?
input: ------ <test> <author> <name><snm>surname</snm><fnm>firstname</fnm></name> </author> <player> <name><snm>surname</snm><fnm>firstname</fnm></name> </player> <some> <here>here some text</here> </some> </test> output: ------- <test> <player> <name><snm>surname</snm><fnm>firstname</fnm></name> </player> <some> <here>here some text</here> <author> <name><snm>surname</snm><fnm>firstname</fnm></name> </author> </some> </test> my $twig = new XML::Twig( pretty_print = +> 'indented' + ); $twig->parse($input); my $pl = XML::Twig::Elt->new("$place"); for ($twig->get_xpath($path)) { $_->cut ; $_->paste('last_child', $pl) ; } $input = $twig->sprint;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Twig 'cut' and 'paste'
by Herkum (Parson) on Jun 09, 2006 at 16:23 UTC | |
by Anonymous Monk on Jun 10, 2006 at 00:45 UTC |