I strongly suspect that you're looking at the debugger. That will show the escaped form, but the quotes won't actually be in the string if they shouldn't be.
I suggest you log the string somehow - then you'll see the real data, and my guess is that it won't contain the backslashes - assuming you haven't written any backslashes to the StringWriter
to start with. How are you writing the data to the StringWriter
? Is it possible that your problems are further upstream? (If you're writing the XML manually, I'd strongly recommend that you use an XML API instead. It's much less error-prone.)
What error are you getting when trying to read the XML back? What does it look like in the database?
I can pretty much guarantee that the problem won't be in StringWriter
or StringBuilder
- they don't perform any escaping.
On another note, is there any reason why you're calling GetStringBuilder().ToString()
instead of just ToString()
?