Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to pull the text from some HTML::Element objects which in this case happen to be elements of type 'td' or table divisions. I can "dump" these elements properly, but for the sake of cleanliness I would prefer to just have the text written in these 'td' objects. E.g.
use HTML::TreeBuilder; my $tree = HTML::TreeBuilder->new; $filename = "websource2.txt"; $tree->parse_file($filename); @tbodies = $tree->find('tbody'); @tds = @tbodies[0]->find('td'); @data = @tds[1..6]; foreach(@data){ $_->dump(); }
... produces the output I expected, but replacing the method call dump() with as_text() or even as_HTML() produces no output or errors. I'm mystified. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: HTML::Element method as_text() not performing as expected on <td> elements
by Anonymous Monk on Aug 31, 2011 at 04:37 UTC | |
by Anonymous Monk on Aug 31, 2011 at 05:40 UTC | |
by Anonymous Monk on Aug 31, 2011 at 06:29 UTC | |
|
Re: HTML::Element method as_text() not performing as expected on <td> elements
by charlesboyo (Beadle) on Aug 30, 2011 at 22:48 UTC |