password has asked for the wisdom of the Perl Monks concerning the following question:
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::TreeBuilder::LibXML creates multiple copies of the same result
by haukex (Archbishop) on Mar 10, 2018 at 20:56 UTC | |
by password (Beadle) on Mar 10, 2018 at 21:08 UTC | |
|
Re: HTML::TreeBuilder::LibXML creates multiple copies of the same result
by Anonymous Monk on Mar 10, 2018 at 22:36 UTC |