Is there a .NET (2.0) framework method to remove the XML special characters?
Like "
&
etc.
It's easy enough to write one, but I'd rather use the framework's if one is available.
Is there a .NET (2.0) framework method to remove the XML special characters?
Like "
&
etc.
It's easy enough to write one, but I'd rather use the framework's if one is available.
Assuming you mean you want to escape the characters, i.e. & becomes & then I don't think there is a framework method for that, closest is probably the HTMLEncode and HTMLDecode on the HTTPServerUtility class. Could always wrap your data in CDATA tags to avoid parsing of those characters.
I suggest taking a look at the XMLConvert class. You can use it to encode and Decode XML to make it safe. This will also handle illegal characters as defined in the XML Spec. Removing characters changes the underlying data and it is better to encode and decode them.