##
TV show 1
Heroes
4
FULL
Page 65
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
FULL
Page 65
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
TV show 2
Prison Break
8
FULL
Page 65
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
FULL
Page 65
-2
-3
5
8
yipppeee
yipppeee
-2
-3
5
8
yipppeee
yipppeee
####
use warnings;
use XML::Twig;
use XML::Simple;
$localfile= "Test_1.xml";
my $field = "Nest1";
open my $fout1, '>', "testx.csv" or die "Could not open file!";
$twig = XML::Twig->new(
twig_roots => {
$field => 1,
'd1' => 1,
'd2'=> 1,
},
twig_handlers => {
'DatatoParse' => \&node,
'DatatoParse//*' => \&node1
}
);
$twig->parsefile($localfile);
sub node {
my($twig, $el) = @_;
$twig->purge;
}
sub node1{
print $fout1 "\n", if ($_->tag eq "d1");
print $fout1 $_->text, ",", unless ($_->has_children('#ELT'));
print $fout1 "\n", if ($_->tag eq "elt");
}