1XML::Grove::Sub(3)    User Contributed Perl Documentation   XML::Grove::Sub(3)
2
3
4

NAME

6       XML::Grove::Sub - run a filter sub over a grove
7

SYNOPSIS

9        use XML::Grove::Sub;
10
11        # Using filter method on XML::Grove::Document or XML::Grove::Element:
12        @results = $grove_object->filter(\&sub [, ...]);
13
14        # Using an XML::Grove::Sub instance:
15        $filterer = XML::Grove::Sub->new();
16        @results = $grove_object->accept($filterer, \&sub [, ...]);
17

DESCRIPTION

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

EXAMPLE

25       The following filter will return a list of all `"foo"' or `"bar"'
26       elements with an attribute `"widget-no"' beginning with `"A"' or `"B"'.
27
28         @results = $grove_obj->filter(sub {
29             my $obj = shift;
30
31             if ($obj->isa('XML::Grove::Element')
32                 && (($obj->{Name} eq 'foo')
33                     || ($obj->{Name} eq 'bar'))
34                 && ($obj->{Attributes}{'widget-no'} =~ /^[AB]/)) {
35                 return ($obj);
36             }
37             return ();
38         });
39

AUTHOR

41       Ken MacLeod, ken@bitsko.slc.ut.us
42

SEE ALSO

44       perl(1), XML::Grove(3), Data::Grove::Visitor(3)
45
46       Extensible Markup Language (XML) <http://www.w3c.org/XML>
47
48
49
50perl v5.12.0                      1999-09-02                XML::Grove::Sub(3)
Impressum