#!/usr/bin/perl
use strict;
use warnings;

use XML::XPath;
use XML::XPath::Node;
use XML::XPath::XMLParser;

my $string = <<XML;
<!DOCTYPE test [<!ENTITY booyah "groovy">]>
<foo>&booyah; dude &amp; others</foo>
XML

my $xp = XML::XPath->new($string);
my $nodeset = $xp->find('//text()');

foreach my $node ($nodeset->get_nodelist) {
    if ($node->getNodeType() == XML::XPath::Node::TEXT_NODE) {
        print "Text: " . $node->getValue() . "\n";
    }
}
