CCCP::ConfigXML - load XML config files or string
Load XML file. Example:
# foo_config.xml <foo> <name>TestApp</name> <component name="Controller::Foo"> <foo>bar</foo> </component> <model name="Baz"> <qux>Stop!</qux> </model> </foo> # bar_config.xml <bar> <val>x1</val> <val>x2</val> <val>x3</val> <val>x4</val> </bar> # baz_config.xml <foo> <model name="Bar"> <qux>Go!</qux> </model> </foo>
In your code:
use CCCP::ConfigXML; # or if you want singletone use CCCP::ConfigXML as => 'singletone'; # like XML::Bare my $cnf = CCCP::ConfigXML->new( file => ['foo_config.xml', 'bar_config.xml'] ); # now, you can read $cnf->{foo}->{name}->{value}; # TestApp $cnf->{foo}->{component}->{foo}->{value}; # bar $cnf->{foo}->{component}->{name}->{value}; # Controller::Foo $cnf->{foo}->{model}->{qux}->{value} # Stop! $cnf->add_file(baz_config.xml); $cnf->{foo}->{model}->{qux}->{value} # Go!
Simple and usefull wrapper on XML::Bare and Hash::Merge::Simple.
Constructor. All arguments are optional. @param_parse - another parametrs for XML::Bare
Extend instance from $file.
Extend instance from xml-string.
By default 0. Set true when
use CCCP::ConfigXML as => 'singletone'; # or use CCCP::ConfigXML; CCCP::ConfigXML->import(as => 'singletone'); # or :) $CCCP::ConfigXML::like_singletone = 1;
When value is true, then new returns a singleton if this is possible.
new
mr.Rico <catamoose at yandex.ru>
To install CCCP::ConfigXML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CCCP::ConfigXML
CPAN shell
perl -MCPAN -e shell install CCCP::ConfigXML
For more information on module installation, please visit the detailed CPAN module installation guide.