in reply to Re: sort order of imported xml data?
in thread sort order of imported xml data?

It is not enough to use ForceArray in this case, because the XML that the OP presents uses key attributes. The regular elements will be forced into an array structure but the key attributes would still live in an unsorted hash.

The solution is to combine ForceArray with the option KeyAttr to also force key attributes into an array.

my $config = XMLin("meep.xlf", ForceArray => 1, KeyAttr =>[]);

NB: This changes the structure that XML::Simple returns so you will need to update your code a little.

I tend to use Data::Dumper to inspect the hash that XML::Simple returns to check if that meets my needs.

Replies are listed 'Best First'.
Re^3: sort order of imported xml data?
by roboticus (Chancellor) on Mar 31, 2007 at 13:46 UTC
    ++varian:

    ...and that's what I get for guessing instead of trying it out.

    Thanks for the catch! (Yarch, two slipped gears on the same day. I'll have to be sure not to skip my morning coffee ... um, err, uh ....oil! Yeah, that's the ticket.....)

    ...roboticus

Re^3: sort order of imported xml data?
by Xenofur (Monk) on Apr 07, 2007 at 02:33 UTC
    Sorry for the late replies, work got over-busy and this project set on the backburner, but i'm back on it and a good step ahead thanks to your input.

    And i have to say, as for quickly solving my problem with the least effort, varian is right on spot! :)
    I should've known that i should've read the documentation more closely. ^^

    Also, yes, i've been basically using Data::Dumper all the time, but cut it out of my example code as not relevant. I however use it to basically reverse construct my access code. =)