SYNOPSIS

 use XML::Grove::Sub;

 # Using filter method on XML::Grove::Document or XML::Grove::Element:
 @results = $grove_object->filter(\&sub [, ...]);

 # Using an XML::Grove::Sub instance:
 $filterer = XML::Grove::Sub->new();
 @results = $grove_object->accept($filterer, \&sub [, ...]);

DESCRIPTION

\*(C`XML::Grove::Sub\*(C' executes a sub, the filter, over all objects in a grove and returns a list of all the return values from the sub. The sub is called with the grove object as it's first parameter and passing the rest of the arguments to the call to `\*(C`filter()\*(C'' or `\*(C`accept()\*(C''.

EXAMPLE

The following filter will return a list of all `\*(C`foo\*(C'' or `\*(C`bar\*(C'' elements with an attribute `\*(C`widget-no\*(C'' beginning with `\*(C`A\*(C'' or `\*(C`B\*(C''.

@results = $grove_obj->filter(sub { my $obj = shift;

if ($obj->isa('XML::Grove::Element') && (($obj->{Name} eq 'foo') || ($obj->{Name} eq 'bar')) && ($obj->{Attributes}{'widget-no'} =~ /^[AB]/)) { return ($obj); } return (); });

AUTHOR

Ken MacLeod, [email protected]

RELATED TO XML::Grove::Sub…

perl\|(1), XML::Grove\|(3), Data::Grove::Visitor\|(3)

Extensible Markup Language (\s-1XML\s0) <http://www.w3c.org/XML>