My XML parser code
my $twig = XML::Twig->new(
twig_handlers => {
'Mughals' => sub {
+ my ($twig, $el) = @_;
+ $twig->purge;
+ },
'Mughals//*' => sub {
+ my $a = $_->tag;
+ if ($a eq "Book")
+ {
+ print $fout1 "\n";
+ print $fout2 "\n";
+ }
#print $fout1 $_->tag, ", ", $_->text, unless ($_->has_
+children('#ELT'));
print $fout2 $_->tag, ",", unless ($_->has_children('#E
+LT'));
print $fout1 $_->text, ",", unless ($_->has_children('#
+ELT'));
}
}
);
$twig->parsefile('book.xml');
This is a part of the code for parsing one part of the file 'Mughals'. The path to Mughals is History->Indian History -> Mughals. I am confused about how to accept this input from the user.