#!/usr/bin/perl use strict; use warnings; use XML::Twig; my $t= XML::Twig->new( keep_spaces => 1, comments => 'drop', twig_handlers => { _all_ => sub { $_[0]->flush }} ) ->parsefile( "test_comments.xml") ;