Sunday, January 2, 2011

Merge Multiple XML files and Parsing with XML::Twig

PERL CODING

use XML::Twig;

 my $xml_dir="E:/Purand/temp";
 my $output="E:/Purand/temp/merge.xml";
 my $file;
 my $merge;

 opendir(DIR, "$xml_dir") || die;

 my @TranscriptsList = grep(/xml$/, readdir(DIR));
 closedir(DIR);

 foreach $file (@TranscriptsList) {

my $twig= new XML::Twig(TwigRoots => {art => 1});

 $twig->parsefile($file);

 $twig->print;

 open XMLOUT, ">>$output";

 $twig->print(\*XMLOUT) or die;

 close XMLOUT;
 }

No comments: