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
PMCG - 31 Jan 2004 16:36 GMT
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