Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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]
[Happy-the-monk]: marto: like not coming back to it until the following day would be my advise to myself.
[marto]: Happy-the-monk very wise

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2018-03-18 18:08 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (230 votes). Check out past polls.