in reply to How to extract untouched content of html tag with HTML::Parser
I need all html formatting to be untouched
Maybe including start and end tags within the div would give you what you want.
sub start_handler { my $self = shift; my $tagname = shift; my $attr = shift; my $text = shift; return unless ( $tagname eq 'div' and $attr->{id} eq 'body' ); $self->handler( start => sub { print shift }, "text" ); $self->handler( text => sub { print shift }, "text" ); $self->handler(end => sub { my ($endtagname, $self, $text) = @_; if($endtagname eq $tagname) { $self->eof; } else { print $text; } }, "tagname,self,text"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to extract untouched content of html tag with HTML::Parser
by Lana (Beadle) on Nov 28, 2010 at 17:35 UTC | |
by Anonymous Monk on Nov 28, 2010 at 20:53 UTC | |
|
Re^2: How to extract untouched content of html tag with HTML::Parser
by SneakZa (Initiate) on May 28, 2013 at 16:34 UTC | |
by ig (Vicar) on Jul 26, 2013 at 17:15 UTC |