--- /dev/null
+package Catalyst::Plugin::ConfigLoader::XML;\r
+\r
+use strict;\r
+use warnings;\r
+\r
+=head1 NAME\r
+\r
+Catalyst::Plugin::ConfigLoader::XML - Load XML config files\r
+\r
+=head1 DESCRIPTION\r
+\r
+Loads XML files. Example:\r
+\r
+ <config>\r
+ <name>TestApp</name>\r
+ <component name="Controller::Config">\r
+ <foo>bar</foo>\r
+ </component>\r
+ </config>\r
+\r
+=head1 METHODS\r
+\r
+=head2 load( $file )\r
+\r
+Attempts to load C<$file> as an XML file.\r
+\r
+=cut\r
+\r
+sub load {\r
+ my $class = shift;\r
+ my $confpath = shift;\r
+\r
+ my $file;\r
+ if( $confpath =~ /\.(.{3})$/ ) {\r
+ return unless $1 eq 'xml';\r
+ $file = $confpath;\r
+ }\r
+ else {\r
+ $file = "$confpath.xml";\r
+ }\r
+ \r
+ return unless -f $file;\r
+\r
+ require XML::Simple;\r
+ XML::Simple->import;\r
+ my $config = XMLin( $file, ForceArray => [ 'component' ] );\r
+\r
+ my $components = delete $config->{ component };\r
+ foreach my $element ( keys %$components ) {\r
+ $config->{ $element } = $components->{ $element };\r
+ }\r
+\r
+ return $config;\r
+}\r
+\r
+=head1 AUTHOR\r
+\r
+=over 4 \r
+\r
+=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
+\r
+=back\r
+\r
+=head1 COPYRIGHT AND LICENSE\r
+\r
+Copyright 2006 by Brian Cassidy\r
+\r
+This library is free software; you can redistribute it and/or modify\r
+it under the same terms as Perl itself. \r
+\r
+=head1 SEE ALSO\r
+\r
+=over 4 \r
+\r
+=item * L<Catalyst>\r
+\r
+=back\r
+\r
+=cut\r
+\r
+1;
\ No newline at end of file