use warnings; use strict; use XML::Twig; my $twig = new XML::Twig( twig_handlers => { item => \&item, }, ); $twig->parsefile('in.xml'); $twig->set_pretty_print('indented'); $twig->print_to_file('out.xml'); sub item { my ( $twig, $item ) = @_; for my $c ($item->children()) { $c->cut($item) unless $c->tag() eq 'id' or $c->tag() eq 'name' ; } }
In reply to Re^3: How to filter XML elements, exclude some
by toolic
in thread How to filter XML elements, exclude some
by ak1234
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |