in reply to Re^2: hash from xml::simple
in thread hash from xml::simple

For your input, I think I'd rather have this output:
$VAR1 = { 'banana' => { 'date' => '1231210' }, 'apple' => { 'time' => '235959', 'date' => '1231210' } };
And I can get that with XML::Rules:
use strict; use warnings; use XML::Rules; use Data::Dumper; my @rules = ( _default => sub { "%".$_[0] => {$_[1]->{name} => $_[1]->{value}}}, main => 'pass no content', ); my $text=<<EOF; <main> <apple name="date" value="1231210"/> <apple name="time" value="235959"/> <banana name="date" value="1231210"/> </main> EOF my $p = XML::Rules->new( rules => \@rules, ); my $x = $p->parse($text); print Dumper $x;