use HTML::TreeBuilder::XPath; my $html = q|
Agave parryi     ...
|; $html =~ s/ / /g; my $tree = HTML::TreeBuilder::XPath->new_from_content($html); my @nodes = $tree->findnodes('//div[@class="listing"]'); for my $node (@nodes) { my @contents = $node->content_list; for my $content (@contents) { if (ref $content) { my $text = $content->as_text or next; my $tag = $content->tag; print "<$tag> $text\n\n"; } else { print "$content\n\n"; } } }