Ratazong has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks!
I'm playing with html-parsing (using HTML::Tree), and am stuck with parsing the following snippet:
I try to parse this with the code below (just a part of the script to show you the idea), and finally want to have the ImportantText1 or ImportantText2 in the variable $name. However I end with the value 1000ImportantText2 in the second case. And somehow I cannot find the part of the documentation which shows me how to replace the as_trimmed_text() so the values of the sub-elements are ignored.<span class="name color1">ImportantText1</span> <span class="name color2"><span class="level">1000</span>ImportantText +2</span>
Please enlighten me!
Rata
my @subsub = $body->look_down (_tag => "span"); foreach my $sss (@subsub) { my $c = $sss->attr("class"); if ($c =~ /name color/) { $name = $sss->as_trimmed_text(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Tree: get value of an element
by poj (Abbot) on Feb 19, 2015 at 16:26 UTC | |
by Ratazong (Monsignor) on Feb 20, 2015 at 07:51 UTC |