use warnings; use strict; use XML::LibXML; my $doc = XML::LibXML->new->parse_fh(\*DATA); # or ->parse_file("news.xml") my $root = $doc->getDocumentElement; my @nodes = $root->findnodes("new"); $root->removeChild($nodes[-1]); # Remove the last. print $doc->serialize();# Or... print $root->serialize(); __DATA__ blah blah blah blah blah blah