in reply to Search and Replace

If you stick in a:
<?xml version="1.0" encoding="iso-8859-1"?>
you'll find that this actually is valid XML. Which means you could go for an XML type solution, either DOM or stream based.

Or you could read the whole file in memory and do regular expressions.

Judging from what you've given us, there is no "best" way. There's just TIMTOWTDI.

Hope this helps.

Liz