in reply to comments on xml 2 hash 2 xml using libXML
I found this when I was browsing for a similar function myself, so I'm sorry for arriving late to the party! :-) I'm just posting this in case anyone else is looking for a similar answer.
There are a couple of CPAN modules which appear to do a similar job. Specifically XML::Hash and XML::Hash::LX.
Both modules predate the 2012 date of the question by a couple of years.
A Monk aims to give answers to those who have none, and to learn from those who know more.