sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
Daniel Lim's Avatar

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 &quot. 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
Oleg Tkachenko [MVP]'s Avatar
Oleg Tkachenko [MVP] November 12th, 2005 03:05 AM
Guest - n/a Posts
#2: Re: How to normalize single and double quotes using XmlSerializer?

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 &quot. 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
 
Not the answer you were looking for? Post your question . . .
196,851 members ready to help you find a solution.
Join Bytes.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.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors