0

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 :)

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by wickedxter
0
#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";
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.