Thread

Posted on Wed Dec 12 03:10:31 2007 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 Wed Dec 12 03:36:21 2007 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 Thu Dec 13 01:38:23 2007 by tirto in response to 6671
Re: how to preserve XML::Simple element order
thanks for the info.
-tirto
Write a response