
morsino
New User
Dec 27, 2010, 2:57 PM
Post #1 of 1
(2272 views)
|
Hi :) I need to display each id of the td markup containing the "alt1Active" class and the content of strong markup that follows the td markup... that's the content of my html page :
<td class="alt1Active" align="right" id="f91"> <div> <a href="forumdisplay.php?f=91"><strong>forum title</strong></a> </div> <div class="smallfont">sub-forum title</div> </td> and my perl code :
#!/usr/bin/perl use strict; #use warnings; use HTML::Parser; my $page = "C:/vb.html"; # création de mon parser my $parser = HTML::Parser->new(); # définition des mes evenements $parser->handler( text => \&text, "text" ); $parser->handler( start => \&start, "tagname,attr" ); $parser->handler( end => \&end, "tagname" ); $parser->parse_file($page); my $i= 0; my $nbre= 0; sub start { my ($tag, $attr) = @_; if ($tag eq 'td' and $attr->{class} eq 'alt1Active' ) { $i= 1; } } sub end { my ($tag) = @_; } sub text { my ($text) = @_; if($i==1){ $nbre++; print "$nbre\n"; print "$text\n"; $i=0; } } that code displays only the plain text including the td markup... How can I display the strong content caming after the td markups... Thanks,
|