Hi monks,
it seems HTML::TreeBuilder::LibXML finds the same node 6 times (3 times if the new lines are removed in the html).
Shouldn't it be just 1 result?
Thank you!!!
use strict; use warnings; use diagnostics; use HTML::TreeBuilder::LibXML; my $body; while (<DATA>) { $body .= $_; } my $tree = HTML::TreeBuilder::LibXML->new_from_content($body); my $xpath = '//div[@class="ccc"]/node()'; my @superCats = $tree->findnodes($xpath); $tree->delete; for my $superCat(@superCats) { my $sc = ${$superCat->parent}{'node'}; print "$sc\n\n"; } exit; __DATA__ <div class="ccc"> <img src=""><h2>Hello</h2> <div class='s'> <a href="/">All</a> </div> </div>
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |