in reply to XML element replacement
...I have had real trouble trying to install libxml etc...
But any XML module has overcome most of the trouble that you might be facing now for your code maintainance.
You should save this possible future time by translating your code into any basic XML (XML::Simple or so). Now that you know exactly what to expect from an XML module, you could choose wisely the best suited, (without requiring libxml). Perhaps, one that transforms every element into a hash key, that would be easy to rename... Use Data::Dumper to test your output for a while...