Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
Check out the new SourceForge HTML5 internet speed test! No Flash necessary and runs on all devices. ×
Programming

Journal Journal: Changing HTML::Element node attributes

I'm working with HTML::Element via HTML::TreeBuilder and its attractive look_down method. I am curious about changing the attributes of a tag for an HTML tree object.

Let's say I start at the root element 'hmtl', and I want to add a summary to the second table.

use LWP::Simple;

my $url = 'http://fire.org/';

my $content = get($url);

use HTML::TreeBuilder;

my $page_tree = HTML::TreeBuilder->new_from_content($content);

my @tables = $page_tree->look_down(_tag=>'table');

my $summary = 'make it for real';

The syntax for setting an attribute is:

$tables[1]->attr('sumary', 'Put your summary here');

The following syntax does NOT work

$tables[1]->attr('summary') = $summary;

Slashdot Top Deals

I'd rather just believe that it's done by little elves running around.

Working...