I currently have a string builder taking the output from an in-memory XSLT transformation. The problem I’m having is when I convert the string builder .ToString() to return the contents it is changing all the quotes to \", eg. <?xml version=\"1.0\" encoding=\"utf-16\"?>, and this is then causing issue reloading the data into an XDocument.
StringBuilder OutputXML = new StringBuilder();
XSLTTransformer.Transform(XmlDoc.CreateReader(), writer);
return OutputXML.ToString();
I’ve tried .Replace("\\\"", "") however this doesn’t work, so how can I prevent/replace these occurances and just keep the string as " so the output is <?xml version="1.0" encoding="utf-16"?>
How are you looking at this string?
Because it sounds like you might be looking at it in a debugger, and the debugger represents ‘”‘ as ‘\”‘.
So the string itself is fine, and will work fine if presented to a user, saved to file, etc. It just looks escaped in the debugger.