Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: XML::Simple, XMLOut() question

by samarzone (Pilgrim)
on Dec 15, 2010 at 14:29 UTC ( #877278=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877278]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2018-05-26 23:55 GMT
Find Nodes?
    Voting Booth?