in reply to Traversing an HTMLTree with HTML:Element ->right
See my second attempt.
This might help illustrate "siblings".
#!/usr/bin/perl use warnings; use strict; use lib q{/www/lib}; use SW::Debug; use HTML::TreeBuilder; my $content = do{local $/;<DATA>}; my $t = HTML::TreeBuilder->new_from_content($content) or die qq{cant build tree}; my $body = $t->look_down(_tag => q{body}); my $p = $t->look_down(_tag => q{p}); my @right = $p->right; print scalar @right, qq{ siblings\n}; for my $ele (@right){ $ele->dump; print q{-} x 20, qq{\n}; } __DATA__ <p id = "1">one</p> <p id = "2">two</p> <p id = "3">three</p>
Which I don't think is what you're after. In the2 siblings <p id="2"> @0.1.1 "two" ---------- <p id="3"> @0.1.2 "three" ----------
loop you want to look down for divs with class = "vcard" and then look down into each of those to get the data you need.foreach my $Node (@PageSections)
The "vcard" divs are children of the "secTitle" divs rather then siblings.
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Traversing an HTMLTree with HTML:Element ->right
by wfsp (Abbot) on Jun 30, 2009 at 09:36 UTC | |
by Anonymous Monk on Jun 30, 2009 at 13:24 UTC |