Sunday, June 20, 2010

Encoding XML Special Characters

To encode string which has XML special characters so that it can be inserted as valid text into xml node, you can use the following API in System.Security namespace.

string s = System.Security.SecurityElement.Escape("<>&");

This will produce the following output:


Labels: ,


Post a Comment

<< Home