Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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


Comment on Re: XML::Simple, XMLOut() question
Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://877278]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (19)
As of 2014-07-29 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (217 votes), past polls