use warnings; use strict; use XML::Twig; my $str = <<EOF; <note> <to> <person>Satan</person> </to> <from via="postcard" russia="with love">moneypenny</from> <heading></heading> <body></body> </note> EOF my $t = XML::Twig->new( pretty_print => 'indented', twig_handlers => { _all_ => sub { $_->delete() unless $_->text() } + } ); $t->parse($str); $t->print(); __END__ <note> <to> <person>Satan</person> </to> <from russia="with love" via="postcard">moneypenny</from> </note>
In reply to Re: prune xml of empty elements
by toolic
in thread prune xml of empty elements
by metaperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |