What's wrong with XML::Simple?
- XMLin( "file") looks pretty concise to me. Even when using the OO mode it is still pretty short: my $config= XML::Simple->new( forcearray => 1);
- I don't know what you mean by Integrate-able with perl OO, you get a clean data structure, what else would you want?
- the forcearray option makes XML::Simple behave sanely I believe.
.
BTW I think your XML structure is not quite optimal, you repeat the X and Y when I believe they should mark a container object (see below).
Finally I have added a simplify method to XML::Twig that should be more or less equivalent to XMLin. It is very much in alpha state at the moment, but if you grab the development version of XML::Twig from xmltwig.com you can try the code below.
So here is the result with XML::Simple and with XML::Twig, output using YAML, both for your XML and for an updated version:
#!/usr/bin/perl -w
use XML::Simple;
use XML::Twig;
use YAML;
$/="\n\n";
my $xml= <DATA>;
print "Original Version:\n";
print "Loaded using XML::Simple: \n",
Dump( XMLin( $xml, forcearray => 1, keyattr => []));
print "Loaded using XML::Twig: \n",
Dump( XML::Twig->new->parse( $xml)->simplify( keyattr => []));
$xml=<DATA>;
print "Original Version:\n";
print "Loaded using XML::Simple: \n",
Dump( XMLin( $xml, forcearray => 1, keyattr => [ 'name', 'type'
+]));
print "Loaded using XML::Twig: \n",
Dump( XML::Twig->new->parse( $xml)->simplify( keyattr => [ 'nam
+e', 'type']));
__DATA__
<?xml version='1.0' standalone='yes'?>
<config name="MyConfig">
<blah name="X" type="T1"> A </blah>
<blah name="X" type="T2"> B </blah>
<blah name="Y" type="T3"> C </blah>
<blah name="Y" type="T4"> D </blah>
<l1 foo1="bar1">
<l2 foo2="bar2">
<l3> Sometext </l3>
</l2>
</l1>
</config>
<?xml version='1.0' standalone='yes'?>
<config name="MyConfig">
<blah name="X">
<foo type="T1"> A </foo>
<foo type="T2"> B </foo>
</blah>
<blah name="Y">
<foo type="T3"> C </foo>
<foo type="T4"> D </foo>
</blah>
<l1 foo1="bar1">
<l2 foo2="bar2">
<l3> Sometext </l3>
</l2>
</l1>
</config>