my $content = get("foo/bar.xml"); die "Couldn't get it!" unless defined $content; my $t= XML::Twig->new( # the twig will include just the root and selected titles twig_roots => { 'summary/div' => \&grabDiv, 'title' => \&grabTitle, 'entry/link' => \&grabLinks } ); $t->parse($content); sub grabDiv { my( $t, $elt)= @_; push ( @divs , $elt->text); # print the text (including sub-element texts) $t->purge; # frees the memory } sub grabTitle { my( $t, $elt)= @_; push( @headlines, $elt->text); # print the text (including sub-element texts) $t->purge; # frees the memory } sub grabLinks { my( $t, $elt)= @_; my $thingey = $elt->{'href'}; push( @links, $elt->text); # print the text (including sub-element texts) $t->purge; # frees the memory } ####