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'};
    or
    $foundit=$tree->{project}{'PlayGround'}{state}{'Development'}{cluster} +{'somthingelse'}{server}{'anotherthing'};
      Does anyone know if this can be done with a different PM?