There's ,no easy solution, I think, because there's probably no XML module around that guarantees that the produced attributes are in the same order as they are parsed.
But XML::Simple guarantees almost absolutely nothing, not even that the output will have a similar structure as the input. It may even move data from content to attribute or vice versa. the only guarantee you get on the output of XML::Simple is that XML::Simple will be able to read it back in.
You might get by with XML::Treebuilder. You build a tree from the original XML, and use XML::Element to find where you want to insert new elements and insert them, then dump the tree back to a file with the appropriate pretty printing. If I have time later I'll try to post a simple example. It's not as simple as XML::Simple, but it's not as much to wade through as XML::LibXML.
XML Twig is so confusing. Is there any post which explains xml twig in detail?
Regexp i cannot use, the parameters are determined by nodes and thus it fails. Can you suggest some good and easy to use module. I have tried hell lot of modules some are good parsers and some are good modifiers but i am unable to find a module which is a good parser as well writer of XML.
Be notified I cannot afford to change my output xml parameters locations.