|The stupid question is the question not asked|
XML::Simple XMLout tag sortingby Skeeve (Vicar)
|on Jan 07, 2014 at 23:56 UTC||Need Help??|
Skeeve has asked for the
wisdom of the Perl Monks concerning the following question:
Dear fellow monks,
I'm using XML::Simple to create some XML files. As the sequence of my tags is important, I was wondering whether it's possible to define the sort order of them. I found this post on stackoverflow: http://stackoverflow.com/questions/1400850/how-can-i-order-tags-in-xmlsimples-output/ which I found quite helpful.
But then I thought that this can be done better and so I created a new constructor for my class which accepts a new configuration option. This way I can define my sortorder when constructing my XML::Simple object.
Now my question is: Could you please check whether or not this can be improved? I'm not so used to this object oriented package stuff. So maybe there is a better way how I can achieve the same result?
For example: I first tried to add my 'SortOrder' configuration option to the @KnownOptOut array of XML::Simple, but couldn't find a way to do that. If that would be possible, no additional constructor would be required. But as I said: I'm not so used to this OO stuff.
Update on the previous paragraph: In the meantime I think, injecting my option into XML::Simple's option array is a bad idea, as it will also affect other objects using XML::Simple.
But here now is my code:
Many thanks in advance for any useful hints!