Posted on 2007-12-12 01:10:31-08 by tirto
how to preserve XML::Simple element order
hi,

in the faq doc , it is mentioned that in the future Tie::IxHash could be use in XML::Simple.

i am using v2.18 at the moment, is there any hack to preserve the order of the data in the hashref?

thanks in advance,

tirto
Direct Responses: 6671 | Write a response
Posted on 2007-12-12 01:36:21-08 by grantm in response to 6670
Re: how to preserve XML::Simple element order

Retaining element order is not and never will be a feature of XML::Simple. For some XML document types you might be able to hack it in by subclassing XML::Simple and overriding the new_hashref() method to supply a hashref tied to Tie::IxHash. That could solve the ABC case but it won't solve the ABA case.

The short answer is that if you care about element order then you should not use XML::Simple. XML::LibXML is an excellent alternative which for many use cases is really no harder to use than XML::Simple - as described in this article.

Direct Responses: 6676 | Write a response
Posted on 2007-12-12 23:38:23-08 by tirto in response to 6671
Re: how to preserve XML::Simple element order
thanks for the info.
-tirto
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.