FB_init

Friday, October 31, 2008

Escaping XML

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



Problem solved.
Note: (To really escape XML, you also need to escape quotes (") and ampersand (&). That is left as an exercise to the reader )

No comments: