[ABE.pm] Using TreeBuilder

Faber Fedor faber at linuxnj.com
Tue Nov 15 14:31:25 PST 2005


Well, I found something that works.  I know why this works, but I don't
know why the previous stuff doesn't work.  

Here's what I'm going to use:


#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder;

my $tree = HTML::TreeBuilder->new;
    $tree->parse_file("simple.html");

my @artists = ( "Kate Bush", "Peter Gabriel");

foreach my $artist (@artists) {    
    my $node = $tree->look_down('_tag', 'tr', 
            sub {
                    $_[0]->as_text =~ m{$artist}
                }
            );

    foreach my $item ($node->content_list()) {
        foreach my $jtem ($item->content_list()){
            print "jtem is $jtem\n";
        }
    }
}

$tree->delete();   

   
exit(0);


Comments?


-- 
 
Regards,
 
Faber Fedor
President
Linux New Jersey, Inc.
908-320-0357
800-706-0701

http://www.linuxnj.com





More information about the ABE-pm mailing list