Re: XML and the .NET Framework How to handle Angled Brackets in Text
Robert Rossney
The only time you'll have trouble with markup characters in text is if you're formulating XML through string manipulation. There are very few circumstances in which this is not a terrible idea.
I can't emphasize that enough. I've seen a lot of code that does this over the last eight or nine years. Nearly all of it has been flawed in some way. (My favorite was in an actual production application in the banking industry that prevented markup characters from showing up in XML messages by applying a regular expression to every form field that transformed them to asterisks!)
You should always form XML documents by using framework classes. Always. If you do this, everything will just work.
There are very few jobs that CDATA is the right tool for. Base64-encoded objects, script code, and embedded XML samples are about the only ones. If you're creating CDATA sections because you want to avoid the work of escaping markup characters, you have taken a very wrong turn.