473,704 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_prepared ocument 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(t ypeof(MyClass))
_Stream = new MemoryStream()
_Writer = new XmlTextWriter(_ Stream, new UTF8Encoding())
_Serializer.Ser ialize(_Writer, _MyClassInstanc e)

_strXmlData = Encoding.UTF8.G etString(_Strea m.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=\"htt p://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"htt p://www.w3.org/2001/XMLSchema-instance\"> ............... ............... .......
Thanks in advanc
Pat
Nov 12 '05 #1
1 12805
Just found this
_Writer.QuoteCh ar = '\'';

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_prepared ocument 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(t ypeof(MyClass)) ;
_Stream = new MemoryStream();
_Writer = new XmlTextWriter(_ Stream, new UTF8Encoding()) ;
_Serializer.Ser ialize(_Writer, _MyClassInstanc e);

_strXmlData = Encoding.UTF8.G etString(_Strea m.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=\"htt p://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"htt p://www.w3.org/2001/XMLSchema-instance\"> ............... ............... ........

Thanks in advance
Pat
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3027
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms to an XML schema (xsd).
5
7287
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace properties.xsd this creates properties.cs
1
5757
by: rmgalante | last post by:
I have a Windows Service that reads and writes an XML file to disk periodically. I use the XmlSerializer to serialize and deserialize the XML file on disk. I am writing the file using an XmlTextWriter and UTF8 encoding. I notice after long periods of time that my file has bad, non-displayable characters. I try to load the XML file with IE, and it tells me that the XML is bad for one of many different reasons, depending on where the bad...
7
22587
by: Steve | last post by:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome" How can I remove charcter to string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
1
1294
by: abcd | last post by:
Case 1 I have a variable called sConnectString whose value is "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\msxp102\shared\DBS\db3.mdb;User Id=;Password=;"; after this I call following statements
4
2338
by: Robert | last post by:
Hello. I have tried to remove the char "\" from a string that I am building in codebehind. to be used in a script tag. I have tried adding (char)34 to the string instead of the escape character, as well as @then double quotes. when i watch the string in the command window or the watch window it has the escape character in the string allways \"
3
2245
by: Guadala Harry | last post by:
I'd like to know the answer to the following question so I can know what to expect with regard to other similar uses of escape characters and strings. While everything works fine - I'd like to know specifically why: I am building a simple HTML table in my C# code-behind by concatenating strings that contain different parts of the table and table content... something like this: string myTable = "<table width=\"100%\" border=\"0\"...
8
5458
by: cd~ | last post by:
I can provide a test app, the news server won't allow me to post the files because they are too large (93KB and 1.2KB) I downloaded the ESRI ArcXml schema and generated the classes from the schema using xsd.exe, which took a while because xsd doesn't handle recursive elements very well (StackOverFlow exception during generation). Now that I have the classes I am trying to serialize them to an xml document to send to ArcIMS to generate...
131
9243
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if you pass a second argument of True (the default is False): 'the "quick" &amp; &lt;brown&gt; fox' 'the &quot;quick&quot; &amp; &lt;brown&gt; fox' This seems to me to be dumb. The default option should be the safe one: that is, escape _all_ the potentially troublesome...
0
8684
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9271
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9025
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8975
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4438
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4699
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3134
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2078
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.