Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / January 2004

Tip: Looking for answers? Try searching our database.

Remove escape characters in XML generated by XMLSerializer ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PMCG - 31 Jan 2004 16:16 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.