for my $foo ($seg->findnodes('foo')) { my $mid = ($foo->findvalue('@mid')); my $mrktext = ($foo->findnodes('text()')); print "$mid $mrktext\n"; }