NAME
CCCP::ConfigXML - load XML config files or string
SYNOPSIS
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!
DESCRIPTION
Simple and usefull wrapper on XML::Bare and Hash::Merge::Simple.
METHODS
new(file => [...list xml-files...], text => [...list xml-string...], @param_parse)
Constructor. All arguments are optional. @param_parse - another parametrs for XML::Bare
add_file($file[, @param_parse])
Extend instance from $file.
add_text($xml_str[, @param_parse])
Extend instance from xml-string.
PACKAGE VARIABLES
$CCCP::ConfigXML::like_singletone
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.
AUTHOR
mr.Rico <catamoose at yandex.ru>