1 package Catalyst::Plugin::ConfigLoader::XML;
\r
8 Catalyst::Plugin::ConfigLoader::XML - Load XML config files
\r
12 Loads XML files. Example:
\r
15 <name>TestApp</name>
\r
16 <component name="Controller::Config">
\r
23 =head2 load( $file )
\r
25 Attempts to load C<$file> as an XML file.
\r
31 my $confpath = shift;
\r
34 if( $confpath =~ /\.(.{3})$/ ) {
\r
35 return unless $1 eq 'xml';
\r
39 $file = "$confpath.xml";
\r
42 return unless -f $file;
\r
44 require XML::Simple;
\r
45 XML::Simple->import;
\r
46 my $config = XMLin( $file, ForceArray => [ 'component' ] );
\r
48 my $components = delete $config->{ component };
\r
49 foreach my $element ( keys %$components ) {
\r
50 $config->{ $element } = $components->{ $element };
\r
60 =item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
\r
64 =head1 COPYRIGHT AND LICENSE
\r
66 Copyright 2006 by Brian Cassidy
\r
68 This library is free software; you can redistribute it and/or modify
\r
69 it under the same terms as Perl itself.
\r