#!/usr/bin/perl -- use warnings; use strict; use XML::Twig; my $str = <<'EOF'; Satan moneypenny EOF my $t = XML::Twig->new( pretty_print => 'indented', twig_handlers => { _all_ => sub { $_->delete() unless $_->has_child or $_->has_atts }, }, ); $t->parse($str); $t->print(); __END__ Satan moneypenny