in reply to Parsing badly formed RSS or XML

Actually you don't have to escape >, only <.

If you replace & by & you will miss all the special characters, so you probably want to use an entity table from the W3C, such as these ones. In this case you don't have to replace & anymore (unless it's followed by a space of course). You would just have to add the entities declaration at the top of the RSS file. You would probably get Unicode characters though, which might break the rest of your processing, YMMV.