in reply to XML::Twig output to filehandle
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>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::Twig output to filehandle
by poolpi (Hermit) on Feb 13, 2009 at 08:30 UTC | |
by mirod (Canon) on Feb 13, 2009 at 08:41 UTC | |
by Anonymous Monk on Feb 13, 2009 at 09:03 UTC | |
by mirod (Canon) on Feb 13, 2009 at 09:32 UTC |