If you don't have nested tables can you just keep track of each table element you get until you've finished parsing the document?
I prefer to use HTML::TokeParser for HTML parsing.
On Saturday, October 26, 2002, at 10:09 PM, [EMAIL PROTECTED] wrote:
hi there,
i have tried to parse a html document, i wanted the last table element
on any document with any numbers of tables in it, one way to do this
is to use perl reverse function and parse it to the handler for the
first table element, but some how this way aren't good because if you
re-reverse the document it don't givs the original contents...
any one know othere way to get the last table element of a html
document?
i have included my handler here to get the first table element:
[code]
$p = HTML::Parser->new( api_version => 3,
start_h => [ sub {
my ($tag,$attr,$self)= @_;
return if $tag ne "table";
$self->handler( start => undef);
$self->handler( end => sub {
my ($tag, $self) = @_;
$self->{'tagend'} =
"table" &&
$self->handler(end =>
undef)
if $tag eq "table"
},"tagname,self");
},"tagname, attr, self"],
default_h => [ sub {
my $self = shift;
print shift unless
$self->{'tagend'}
}, "self,text"]);
______________________________________________________________________
Beskyt din computer mod virus og misbrug! L�s mere i Yahoo! Sikkerhedscenter p� www.yahoo.dk/sikkerhedscenter
