poj#!perl use strict; use HTML::TreeBuilder; my $body = HTML::TreeBuilder->new_from_file(\*DATA); my @subsub = $body->look_down (_tag => "span"); foreach my $sss (@subsub) { my $c = $sss->attr("class"); if ($c =~ /name color/){ # ignore sub elements for ( $sss->descendants() ){ $_->detach(); }; my $name = $sss->as_trimmed_text(); print $name."\n"; } } __DATA__ <span class="name color1">ImportantText1</span> <span class="name color2"><span class="level">1000</span>ImportantText +2</span>
In reply to Re: HTML::Tree: get value of an element
by poj
in thread HTML::Tree: get value of an element
by Ratazong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |