XmlDocument extension method to create CData sections with CData terminators inside


/ Published in: C#
Save to your folder(s)

XmlDocument will not behave when you try to CreateCDataSection passing it a string that contains "]]>"

This extension method returns an array of XmlCDataSection, each of which will contain the parts separated by "]]" and ">". Example:

For the string "This string contains ]]>, and ]]> is invalid within CData sections", the return value will be an array containing the following XmlCDataSections:

"This string contains ]]"
">, and ]]"
"> is invalid within CData sections"

which works beautifully.

Optimizations are welcome.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.