App-Mowyw

 view release on metacpan or  search on metacpan

lib/App/Mowyw/Datasource/XML.pm  view on Meta::CPAN


use Carp qw(confess);

sub new {
    my ($class, $opts) = @_;
    my $self = bless { OPTIONS => $opts, INDEX => 0 }, $class;

    my $file = $opts->{file} or confess "Mandatory option 'file' is missing\n";
    $opts->{source} = $self->_read_data($file);
#    print Dumper $opts;
    $self = $self->SUPER::new($opts);

    return $self;
}

sub _read_data {
    my ($self, $file) = @_;
    my $data;
    if (exists $self->{OPTIONS}{root}){
        $data = XML::Simple->new->parse_file($file, ForceArray => [ $self->{OPTIONS}{root} ]);
    } else {



( run in 0.346 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )