#!/usr/bin/perl -w # print text from 'title' nodes in file 'darwin.xml' using XML::Twig. use strict; use XML::Twig; my $file = 'darwin.xml'; my $twig = new XML::Twig( TwigRoots => { title => 1 }, TwigHandlers => { title => \&titleHandler }, ); $twig->parsefile($file); sub titleHandler { my ($twig, $elt) = @_; print $elt->text . "\n"; }