CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Html Parser

 



morsino
New User

Dec 27, 2010, 2:57 PM

Post #1 of 1 (1277 views)
Html Parser Can't Post

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 :


Code
<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 :

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,

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives