my $p = $frame->getElementsByTagName('contact:update'); foreach my $n ($p->[0]->childNodes()) { $p->[0]->removeChild($n) if $n->toString(1) eq ""; }