use strict;
use XML::Twig;
my $sel = 'title';
my $ign = 'title/title/title';
my $twig = XML::Twig->new(
ignore_elts => { "$ign" => 1},
twig_handlers => { "$sel" => \&title},
pretty_print => 'indented'
);
$twig->parsefile('1.xml');
$twig->print;
sub title
{
my ($twig, $tit) = @_;
$tit->set_gi('tit');
}
####
input:
testingHouston, Allan6920.13.42.814
testingHouston, Allan6920.13.42.814
Raja m49
testing the sub title in title
this is pcdata in subtitle
second sub level
####
output:
testingHouston, Allan6920.13.42.814
testingHouston, Allan6920.13.42.814
Raja m
49
testing the sub title in title
this is pcdata in subtitle
####
Expected output:
testingHouston, Allan6920.13.42.814
testingHouston, Allan6920.13.42.814
Raja m
49
testing the sub title in title
this is pcdata in subtitle
second sub level