472,093 Members | 2,500 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,093 software developers and data experts.

Remove escape characters in XML generated by XMLSerializer ?

Hi
I am using the XMLSerializer class to serialize a custom class into a memory stream whose contents i then pass to a MSSQL SP that uses the sp_xml_preparedocument SP, i can serialize the class but get secape characters in the XML when i read from the memory stream. I do not know much about encoding so i may be missing something very obvious here, heres some of the cod

_Serializer = new XmlSerializer(typeof(MyClass))
_Stream = new MemoryStream()
_Writer = new XmlTextWriter(_Stream, new UTF8Encoding())
_Serializer.Serialize(_Writer, _MyClassInstance)

_strXmlData = Encoding.UTF8.GetString(_Stream.ToArray())

I get the following XML, i need to get XML without the escape character

<?xml version=\"1.0\" encoding=\"utf-8\"?><c-c xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> .....................................
Thanks in advanc
Pat
Nov 12 '05 #1
1 12324
Just found this
_Writer.QuoteChar = '\'';

Used to control which character to use to quote attribute values.
Apologies for not picking this up.
Pat
----- PMCG wrote: -----

Hi,
I am using the XMLSerializer class to serialize a custom class into a memory stream whose contents i then pass to a MSSQL SP that uses the sp_xml_preparedocument SP, i can serialize the class but get secape characters in the XML when i read from the memory stream. I do not know much about encoding so i may be missing something very obvious here, heres some of the code

_Serializer = new XmlSerializer(typeof(MyClass));
_Stream = new MemoryStream();
_Writer = new XmlTextWriter(_Stream, new UTF8Encoding());
_Serializer.Serialize(_Writer, _MyClassInstance);

_strXmlData = Encoding.UTF8.GetString(_Stream.ToArray());
I get the following XML, i need to get XML without the escape characters

<?xml version=\"1.0\" encoding=\"utf-8\"?><c-c xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> ......................................

Thanks in advance
Pat
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by keith bannister via .NET 247 | last post: by
7 posts views Thread by Steve | last post: by
1 post views Thread by abcd | last post: by
4 posts views Thread by Robert | last post: by
3 posts views Thread by Guadala Harry | last post: by
131 posts views Thread by Lawrence D'Oliveiro | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.