#!/usr/bin/perl -- use strict; use warnings; use XML::LibXML; my $dom = XML::LibXML->new( qw/ recover 2 / )->load_html( location => q{junk.html} ); for ( $dom->findnodes(q{ //div[ contains( @class, 'lastUnit' ) ] }) ){ print "\n", $_->nodePath, "\n\n$_\n"; } __END__