How to normalize single and double quotes using XmlSerializer?
Question posted by: Daniel Lim
(Guest)
on
November 12th, 2005 03:04 AM
When using XmlSerializer, I notice that it does not normalize the
single quote and double quote characters, i.e. does not change ' to
' and " to ". However, it does normalize other characters,
like changing ampersand to &
Here is my code:
---- start of code --------
MyClass *myClass = MyClass() ;
XmlSerializer *xs = new XmlSerializer( __typeof( MyClass ) ) ;
StringWriter *sw = new StringWriter() ;
xs->Serialize( sw, myClass ) ;
String xmlResult = sw->ToString() ;
---- end of code --------
Is this a inherent property of XmlSerializer that cannot be changed?
If the answer is yes, is there other .Net classes that will provide
normalization for single and double quotes? Thanks.
1
Answer Posted
Daniel Lim wrote:
[color=blue]
> When using XmlSerializer, I notice that it does not normalize the
> single quote and double quote characters, i.e. does not change ' to
> ' and " to ". However, it does normalize other characters,
> like changing ampersand to &[/color]
That's because only & and < characters *must* be escaped in XML.
--
Oleg Tkachenko [XML MVP, XmlInsider]
http://blog.tkachenko.com
|
|
|
What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 196,851 network members.
Top Community Contributors
|