Wednesday, April 2, 2008

Replace invalid XML characters in a string

May be some of us try to write custom replace methods to clean any invalid XML characters from our xml strings. Well, System.Security namespace has the Escape method built-in which does the same for us. Check it out at MSDN - Escape method. The code would look like:

tagText = SecurityElement.Escape(tagText);

Love coding!

1 comment:

Anonymous said...

Thanks. Just what I needed!