pod fixes
[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
19 </config>\r
20\r
21=head1 METHODS\r
22\r
c7413665 23=head2 extensions( )\r
24\r
25return an array of valid extensions (C<xml>).\r
26\r
27=cut\r
28\r
29sub extensions {\r
30 return qw( xml );\r
31}\r
32\r
b2d85594 33=head2 load( $file )\r
34\r
35Attempts to load C<$file> as an XML file.\r
36\r
37=cut\r
38\r
39sub load {\r
c7413665 40 my $class = shift;\r
41 my $file = shift;\r
b2d85594 42\r
43 require XML::Simple;\r
44 XML::Simple->import;\r
c7413665 45 my $config = XMLin( $file, ForceArray => [ 'component' ] );\r
b2d85594 46\r
47 my $components = delete $config->{ component };\r
48 foreach my $element ( keys %$components ) {\r
49 $config->{ $element } = $components->{ $element };\r
50 }\r
51\r
52 return $config;\r
53}\r
54\r
55=head1 AUTHOR\r
56\r
57=over 4 \r
58\r
59=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
60\r
61=back\r
62\r
63=head1 COPYRIGHT AND LICENSE\r
64\r
65Copyright 2006 by Brian Cassidy\r
66\r
67This library is free software; you can redistribute it and/or modify\r
68it under the same terms as Perl itself. \r
69\r
70=head1 SEE ALSO\r
71\r
72=over 4 \r
73\r
74=item * L<Catalyst>\r
75\r
d6277728 76=item * L<Catalyst::Plugin::ConfigLoader>\r
c7413665 77\r
b2d85594 78=back\r
79\r
80=cut\r
81\r
821;