#dd.xml is a flie like this:
#
#
# a
# 2003-11-27 18:00
# Title
# Link a 1
# Link a 2
# 1
#
#
# b
## 2003-11-27 19:00
# Title b
# Link b
# 0
#
#
# b
## 2003-11-27 18:00
# Title b
# Link c
# 0
#
#
####
use strict;
my $list = new List;
my $file = './dd.xml';
$list->set_items($file);
$list->show();
package List;
use strict;
use XML::Simple;
use Data::Dumper;
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
$self->{Items} = ();
return $self;
}
sub set_items {
my $self = shift();
my $file = shift();
# Here I load the xml file
my %tmp = %{XMLin($file,noattr=>1)};
$self->{Items} = $tmp{Item};
# my $d = Dumper(\$self);
# print "$d\n";
}
sub show {
my $self = shift();
my $q = shift();
# Here I build the array of hashes
my @items = @{$self->{Items}};
# my $d = Dumper(\@items);
# print "$d\n";
my $i;
for $i (0..$#items) {
print "-------------\n";
my %hash = %{$items[$i]};
my $d = Dumper(\%hash);
print "$d\n";
# my $date = $hash{Date};
}
}
1;