use XML::Simple; use Data::Dumper; my $x =< a a b EOF $x = XMLin( $x, #SuppressEmpty => '', ForceArray => 1, ContentKey => '-content', ); print Dumper(\$x); $VAR1 = \{ 'obj' => [ { 'class' => 'myclass', 'set' => { 'key2' => {}, 'key1' => { 'content' => 'a' } } }, { 'class' => 'myclass', 'set' => { 'key2' => 'b', 'key1' => 'a' } } ], 'name' => 'me' }; #### 'key2' => 'b', 'key1' => 'a'