added Config::General support
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader / XML.pm
CommitLineData
b2d85594 1package Catalyst::Plugin::ConfigLoader::XML;\r
2\r
3use strict;\r
4use warnings;\r
5\r
6=head1 NAME\r
7\r
8Catalyst::Plugin::ConfigLoader::XML - Load XML config files\r
9\r
10=head1 DESCRIPTION\r
11\r
12Loads XML files. Example:\r
13\r
14 <config>\r
15 <name>TestApp</name>\r
c7413665 16 <component name="Controller::Foo">\r
b2d85594 17 <foo>bar</foo>\r
18 </component>\r
1502c009 19 <model name="Baz">\r
20 <qux>xyzzy</qux>\r
21 </model>\r
b2d85594 22 </config>\r
23\r
24=head1 METHODS\r
25\r
c7413665 26=head2 extensions( )\r
27\r
28return an array of valid extensions (C<xml>).\r
29\r
30=cut\r
31\r
32sub extensions {\r
33 return qw( xml );\r
34}\r
35\r
b2d85594 36=head2 load( $file )\r
37\r
38Attempts to load C<$file> as an XML file.\r
39\r
40=cut\r
41\r
42sub load {\r
c7413665 43 my $class = shift;\r
44 my $file = shift;\r
b2d85594 45\r
46 require XML::Simple;\r
47 XML::Simple->import;\r
1502c009 48 my $config = XMLin( $file, ForceArray => [ qw( component model view controller ) ] );\r
b2d85594 49\r
50 return $config;\r
51}\r
52\r
53=head1 AUTHOR\r
54\r
55=over 4 \r
56\r
57=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
58\r
59=back\r
60\r
61=head1 COPYRIGHT AND LICENSE\r
62\r
63Copyright 2006 by Brian Cassidy\r
64\r
65This library is free software; you can redistribute it and/or modify\r
66it under the same terms as Perl itself. \r
67\r
68=head1 SEE ALSO\r
69\r
70=over 4 \r
71\r
72=item * L<Catalyst>\r
73\r
d6277728 74=item * L<Catalyst::Plugin::ConfigLoader>\r
c7413665 75\r
9a294f32 76=item * L<XML::Simple>\r
77\r
b2d85594 78=back\r
79\r
80=cut\r
81\r
821;