in reply to Building XML Index File
This looks like a perfect fit for XML::Twig. If you post an example of your data and of the result you want to get I can be more precise.
As for whether it would be considered clean... ;--)