in reply to Re: XML::Twig - setting text and elements
in thread XML::Twig - setting text and elements
So dom style http://xmltwig.org
#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; my $t = XML::Twig->new( pretty_print => 'indented' ); $t->xparse(q{<roooooo> <citreference id="mycite"> <linktext> <keyword conref="ds"/> support for IPv6 addresses</linktext> </citreference> <moops></moops> </roooooo>}); $t->print; my( @links ) = $t->findnodes( '//linktext' ); my( $moops ) = $t->findnodes( '//moops' ); for my $link ( @links ){ print $link->path, "\n"; $link->cut->paste( $moops ); } $t->print; __END__ <roooooo> <citreference id="mycite"> <linktext><keyword conref="ds"/> support for IPv6 addresses</linkt +ext> </citreference> <moops></moops> </roooooo> /roooooo/citreference/linktext <roooooo> <citreference id="mycite"></citreference> <moops> <linktext><keyword conref="ds"/> support for IPv6 addresses</linkt +ext> </moops> </roooooo>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: XML::Twig - setting text and elements ( reparent move cut detach )
by slugger415 (Monk) on Sep 10, 2015 at 20:15 UTC |