in reply to Parsing and converting HTML
Try writing a recursive function using content_list method of HTML::Element.
For example,
my $html = HTML::TreeBuilder->new_from_content("$text") || die "$@\n"; sub to_text { if (ref $_[0] eq "HTML::Element") { foreach my $sub_element ($_[0]->content_list) { &to_text($sub_element); } } else { print qq{text="$_[0]"}; } } &to_text($html);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing and converting HTML
by tevolo (Novice) on Jul 26, 2012 at 23:54 UTC | |
by aitap (Curate) on Jul 27, 2012 at 07:28 UTC | |
by Anonymous Monk on Jul 26, 2012 at 23:59 UTC | |
|
Re^2: Parsing and converting HTML
by tevolo (Novice) on Jul 26, 2012 at 19:15 UTC |