in reply to XML::Simple, XMLOut() question

On the first sight it seems that you will have to change your structure to following -

'user' => { 'favorites' => { 'item' => [ { 'title' => 'Book1','genre' => '5','author' => 'Someone' }, { 'title' => 'Book2','genre' => '1','author' => 'Someone' } ] } }
-- Regards - Samar

Replies are listed 'Best First'.
Re^2: XML::Simple, XMLOut() question
by duesouth (Initiate) on Dec 15, 2010 at 14:52 UTC
    Thinking along the same lines. Means looping through the anon array of hashes returned by the query to extract a users favorites and adding the parent key 'item' to each, could work though will give it a try.

      You need not loop. Following would suffice

      $x->{user}->{favorites} = {item => $x->{user}->{favorites}};

      where $x is your original structure


      -- Regards - Samar
        Many thanks, that's done the trick.