Hello,
I have a large number of xml files in a folder. I want to read and extract the content of each xml file to a new.txt. I'm only interested in the content having the tag <Texte>, and i want to create a .txt file (a texte file for each of my xml's). I use the perl modules xml twig and xml simple. There's the code i have until now:
my $xml_dir="C:\xmlperl";
my $output="C:\xmlperl\output.txt";
my $file = $ARGV[0];
opendir(DIR,$xml_dir) || die;
my @TranscriptsList = grep(/xml$/, readdir(DIR));
closedir(DIR);
foreach $file (@TranscriptsList) {
my $twig= new XML::Twig(TwigRoots => {Texte => 1});
$twig->parsefile($file);
$twig->print;
open XMLOUT, '>>C:\xmlperl\output.txt';
$twig->print(\*XMLOUT) or die;
close XMLOUT;
}
As you can see, i can only print in a single .txt file the output of the xml content. Can you help me please?
thank you in advance
I have a large number of xml files in a folder. I want to read and extract the content of each xml file to a new.txt. I'm only interested in the content having the tag <Texte>, and i want to create a .txt file (a texte file for each of my xml's). I use the perl modules xml twig and xml simple. There's the code i have until now:
my $xml_dir="C:\xmlperl";
my $output="C:\xmlperl\output.txt";
my $file = $ARGV[0];
opendir(DIR,$xml_dir) || die;
my @TranscriptsList = grep(/xml$/, readdir(DIR));
closedir(DIR);
foreach $file (@TranscriptsList) {
my $twig= new XML::Twig(TwigRoots => {Texte => 1});
$twig->parsefile($file);
$twig->print;
open XMLOUT, '>>C:\xmlperl\output.txt';
$twig->print(\*XMLOUT) or die;
close XMLOUT;
}
As you can see, i can only print in a single .txt file the output of the xml content. Can you help me please?
thank you in advance