I don't understand why this module is taking any account at all of the linked DTD document, as it is doing no validity check as far as I can see.
In addition, while the module allows for changing and adding to the nodes of a document, there is no obvious method to remove nodes.
However, the comments that you want to exclude are children of the root nodes, so they can be removed effectively by re-rooting the document on the only element child of the root node.
This code demonstrates
use strict;
use warnings;
use autodie;
use 5.010;
use XML::XPath;
my $xp = XML::XPath->new( ioref => *DATA );
my ($new_root) = $xp->findnodes('/*');
print $new_root->toString, "\n";
__DATA__
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<filter>
<filter-name>LocaleFilter</filter-name>
</filter>
</web-app>
output
<web-app>
<filter>
<filter-name>LocaleFilter</filter-name>
</filter>
</web-app>