Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
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
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?
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 rifling through the Monastery: (14)
As of 2015-07-31 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls