I had a requirement to escape XML. It was easier for me to work with escaped XML and encode it at the end only. I couldn't find an 'ubiquitous' tool to encode it. So I did the minimum to get it done.
Ingredient: XML text, unencoded
Step 1: Get sed (sed for Windows, in my case)
Step 2: In a prompt, type
Note: (To really escape XML, you also need to escape quotes (") and ampersand (&). That is left as an exercise to the reader )