Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: XML::Simple : element vs. attribute in XMLout

by Krambambuli (Deacon)
on May 26, 2010 at 13:20 UTC ( #841724=note: print w/ replies, xml ) Need Help??


in reply to XML::Simple : element vs. attribute in XMLout

It seems that if the structure would have been obtained using XMLin with

forcearray => [ qw(arr mod subarr) ]
then the hash would be what XMLOut needs. Wouldn't that fit ?


Comment on Re: XML::Simple : element vs. attribute in XMLout
Download Code
Re^2: XML::Simple : element vs. attribute in XMLout
by rovf (Priest) on May 26, 2010 at 13:32 UTC
    This is likely correct. I haven't checked this yet, because I was hoping for a solution which would work with the *present* internal representation, because it would spare me from modifying existing code which already assumes the hash to be constructed in the way it is right now.


    -- 
    Ronald Fischer <ynnor@mm.st>

      You can always transform the tree programmatically before XMLout.

      for my $elem (@{ $tree->{arr}{elem} }) { $elem->{mod}{content} = delete($elem->{mod}); }

      For what it's worth, keep in mind your existing code will break if a mod element acquires an attribute. (Don't you love the fragility of XML::Simple?)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-04 05:03 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 (57 votes), past polls