poj#!perl 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 ($t,$e) = @_; for ($e->children){ $_->delete unless ($_->name =~ /^id|name$/); } }
In reply to Re^3: How to filter XML elements, exclude some
by poj
in thread How to filter XML elements, exclude some
by ak1234
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |