Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: XML::Simple hash tree structure not consistent

by osunderdog (Deacon)
on Mar 29, 2007 at 18:32 UTC ( #607321=note: print w/replies, xml ) Need Help??

in reply to XML::Simple hash tree structure not consistent

Well, part of the answer might be this:

my $simple = XML::Simple->new( KeepRoot=>1, #I usually keep the root. KeyAttr=>[], #do not use attributes as h +ash keys ForceArray => 1 #force array wrapping to + keep order );

But I'm not sure you can have you're cake and eat it too on the criteria that:

print "2", Dumper( $tree->{project}{'PlayGround'} ) ; # want this + all the time.

Anytime you want to reference something through the hash, you're giving up your ability to predictably order them.

Also note that I put these attributes on the XML::Simple instantiation rather than on the XMLin call. I would recommend you put this XML::Simple instance in the main and pass a reference to it to the xml1 function.

Hazah! I'm Employed!

Replies are listed 'Best First'.
Re^2: XML::Simple hash tree structure not consistent
by riddlemethisbatman (Initiate) on Mar 29, 2007 at 19:44 UTC
    I already have code that will loop through $tree but in this case I don't care about the order. I just need to access the values within or see if any values exist.

    for example:
    $foundit=$tree->{'PlayGround'}{'Development'}{'somthingelse'}{'another +thing'};
    $foundit=$tree->{project}{'PlayGround'}{state}{'Development'}{cluster} +{'somthingelse'}{server}{'anotherthing'};
      Does anyone know if this can be done with a different PM?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2020-12-05 11:46 GMT
Find Nodes?
    Voting Booth?
    How often do you use taint mode?

    Results (63 votes). Check out past polls.