in reply to Re: Walk through HTML::Treebuilder
in thread Walk through HTML::Treebuilder

add_address_attr($tree); sub add_address_attr { my $self = shift; for (@{$self->{'_content'}}) { if (ref $_) { # element $_->attr(addr => $_->address ); add_address_attr ($_); # recurse } } }

Replies are listed 'Best First'.
Re^3: Walk through HTML::Treebuilder
by perlmonkdr (Beadle) on Jan 06, 2008 at 15:55 UTC

    I really don't occurred to me walk through the hash, thanks you very good and beautiful solution.

    I was looking for some method that walk to it, but this is a great idea

    Thank you again

Re^3: Walk through HTML::Treebuilder
by Tux (Canon) on Jan 08, 2008 at 11:47 UTC

    combined with the solution I proposed, that would be even more short and simple:

    $tree->parse_content (<DATA>); $_->attr ("addr", $_->address) for $tree->look_down (_tag => qr{.});

    I never knew about the address property. Thanks, very useful


    Enjoy, Have FUN! H.Merijn