Maybe an alternative to using XML::Twig would be using XML::SAX to build your own internal hash and pass it out. It could be a much simpler alternative than trying to load the entire then and parse it out with the DOM.
Guns don't kill people, ninjas do.