my $xs = XML::Simple->new( forcearray => [ 'item' ], keyattr => { item => 'id' }, rootname => 'opt', ); my $opt = $xs->XMLin(\*DATA);