Wednesday, June 30, 2010

Replacing Characters in String Literals for XML Files

In XML there are certain ASCII characters in literal strings you can not use such as quotes (single and double), ampersands, and a couple others. To replace Characters in String Literals to put into XML use the following segments.

Item = "R:\Sample & Path\test\am's this code is full of & stuff's"
string temp = Item;
temp = temp.Replace("&", "&");
temp = temp.Replace("'", "'");

No comments:

Post a Comment