Hi,

If it's not too much trouble I would appreciate some help with this: How I can read one by ane all xml files in one directory and to have options to get same elemests from xml files :)

For example:

chdir("/ras-events/Emanuila/edrs/") or die "Couldn't open directory";
opendir (DIR, ".") or die "Couldn't open directory";
my @files = grep {/.*?\.xml/}  readdir DIR;
close DIR;
my $file;

$xml = new XML::Simple;
foreach $file (@files) {
   $data = $xml->XMLin("/ras-events/Emanuila/edrs/$file");
   print STDOUT "$file\n";
   print Dumper($data);
   print STDOUT "Volume: $data->{edrs}->[0]->{edr}->[0]->{volume}\n";
}

Thanks in advance for your time :)

#chdir("/ras-events/Emanuila/edrs/") or die "Couldn't open directory";
opendir (DIR, "./ras-events/Emanuila/edrs/") or die "Couldn't open directory";
my @files = readdir(DIR);
closedir DIR;


$xml = new XML::Simple;
foreach my $file (@files) {
   next unless $file =~ /\w+\.xml/;  

   my $data = $xml->XMLin("/ras-events/Emanuila/edrs/$file");
   print STDOUT "$file\n";
   print Dumper($data);
   print STDOUT "Volume: $data->{edrs}->[0]->{edr}->[0]->{volume}\n";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.