Output:use HTML::TreeBuilder::XPath; my $html = q|<div class="listing"> Agave parryi ... </div>|; $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"; } } }
Agave parryi <span> Parry's agave $20.00 3 quart $12.00 Quart <span> Native Sun to part shade Zones 5-10 Family: <i> Amaryllidaceae From the Southwest comes this lovely agave. Thick spiny leaves adorn t +his hardy agave. Ultimate clump size is about 36" with each leaf bein +g maybe 5" across. The flower stalk can reach 12 feet tall. Please pl +ant in well drained soil in a place where children don't play. <span> Hummingbirds
In reply to Re: HTML Parsing (ick)
by tangent
in thread HTML Parsing (ick)
by dbarron
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |