I modified the input to consolidate the information, but the same concept applies:
use warnings;
use strict;
use XML::Twig;
undef $/;
my $XML = <DATA>;
open my $OUT, '>', '/tmp/twig_out' or die "Can't open file: $!";
my $twig = XML::Twig->new(
twig_handlers => {
name => sub {
### If you want the text.
if (1) {
print $OUT $_->text(), "\n";
}
### If you want the elements.
else {
$_->print($OUT);
}
}
}
);
$twig->parse($XML);
close $OUT or die $!;
__DATA__
<script type="ApplicationPerspective" version="5.3.13.179" recorder="8
+.6.59.276" sav="25" guid="296A95D0-E8B6-4989-AA21-126796A3AD3F" xmlns
+="http://www.keynote.com/namespaces/tstp/script">
<name>
<![CDATA[GT Amadeus]]>
</name>
<actions>
<action FrameErrorFatal="1" MetaErrorFatal="1">
<name>
<![CDATA[Home Page]]>
</name>
<description>
<![CDATA[]]>
</description>
</action>
</actions>
</script>