My XML file looks something like this:
Grab an XML parser off the CPAN and use it. They're there for a reason.
Once you've done that, it's some fairly simple XPath expressions to get the nodes you want, and then some quick text replacement on the specific attributes themselves.