I am using a xlmserializer , to write into a file .
serializer.Serialize(writer, po, ns)
Everything works fine.
But instead of writing into a file, i want serialize into a string.
How can I do this ???
Thanks for any hint
Peter 6 2690
Hi,
Try this :
------------------------------------------
' I assume po is the object you want to serialize.
Dim sw as New StringWriter()
serializer.Serialize(sw, po)
' Get the serialized string
Console.WriteLine(sw.ToString())
------------------------------------------
HTH,
Regards,
Cerebrus.
Thanks a lot :
The result for serialization is:
<?xml version="1.0" encoding="utf-16"?>
.....
But how can I controt which encoding is used ??
Now always UTF-16 is used.
But I need ti use utf-8
How can i switch to utf-8 instead of using itf-16 ?
Peter
"Cerebrus" <zo*****@sify.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com... Hi,
Try this : ------------------------------------------ ' I assume po is the object you want to serialize. Dim sw as New StringWriter() serializer.Serialize(sw, po) ' Get the serialized string Console.WriteLine(sw.ToString()) ------------------------------------------ HTH,
Regards,
Cerebrus.
Try setting the StringWriter.Encoding property to Encoding.UTF8Encoding?
======================
Clive Dixon
Digita Ltd. ( www.digita.com)
"Peter Stojkovic" <ds*@gmx.net> wrote in message
news:ui**************@TK2MSFTNGP03.phx.gbl... Thanks a lot :
The result for serialization is:
<?xml version="1.0" encoding="utf-16"?> ....
But how can I controt which encoding is used ?? Now always UTF-16 is used. But I need ti use utf-8
How can i switch to utf-8 instead of using itf-16 ?
Peter
"Cerebrus" <zo*****@sify.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com... Hi,
Try this : ------------------------------------------ ' I assume po is the object you want to serialize. Dim sw as New StringWriter() serializer.Serialize(sw, po) ' Get the serialized string Console.WriteLine(sw.ToString()) ------------------------------------------ HTH,
Regards,
Cerebrus.
....but remember that the string you get still consists of a sequence of
16-bit characters.
======================
Clive Dixon
Digita Ltd. ( www.digita.com)
"Peter Stojkovic" <ds*@gmx.net> wrote in message
news:ui**************@TK2MSFTNGP03.phx.gbl... Thanks a lot :
The result for serialization is:
<?xml version="1.0" encoding="utf-16"?> ....
But how can I controt which encoding is used ?? Now always UTF-16 is used. But I need ti use utf-8
How can i switch to utf-8 instead of using itf-16 ?
Peter
"Cerebrus" <zo*****@sify.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com... Hi,
Try this : ------------------------------------------ ' I assume po is the object you want to serialize. Dim sw as New StringWriter() serializer.Serialize(sw, po) ' Get the serialized string Console.WriteLine(sw.ToString()) ------------------------------------------ HTH,
Regards,
Cerebrus.
The endoding is readonly.
"Clive Dixon" <cl*******************@digita.noluncheonmeat.com > wrote in
message news:eh*************@TK2MSFTNGP04.phx.gbl... Try setting the StringWriter.Encoding property to Encoding.UTF8Encoding?
====================== Clive Dixon Digita Ltd. (www.digita.com)
"Peter Stojkovic" <ds*@gmx.net> wrote in message news:ui**************@TK2MSFTNGP03.phx.gbl... Thanks a lot :
The result for serialization is:
<?xml version="1.0" encoding="utf-16"?> ....
But how can I controt which encoding is used ?? Now always UTF-16 is used. But I need ti use utf-8
How can i switch to utf-8 instead of using itf-16 ?
Peter
"Cerebrus" <zo*****@sify.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com... Hi,
Try this : ------------------------------------------ ' I assume po is the object you want to serialize. Dim sw as New StringWriter() serializer.Serialize(sw, po) ' Get the serialized string Console.WriteLine(sw.ToString()) ------------------------------------------ HTH,
Regards,
Cerebrus.
Sorry yes, that's what comes from trying to quote from vague memory. I think
the answer is to derive your own class from StringWriter and override the
virtual Encoding property to return UTF8Encoding.
======================
Clive Dixon
Digita Ltd. ( www.digita.com)
"Peter Stojkovic" <ds*@gmx.net> wrote in message
news:%2***************@TK2MSFTNGP05.phx.gbl... The endoding is readonly.
"Clive Dixon" <cl*******************@digita.noluncheonmeat.com > wrote in message news:eh*************@TK2MSFTNGP04.phx.gbl... Try setting the StringWriter.Encoding property to Encoding.UTF8Encoding?
====================== Clive Dixon Digita Ltd. (www.digita.com)
"Peter Stojkovic" <ds*@gmx.net> wrote in message news:ui**************@TK2MSFTNGP03.phx.gbl... Thanks a lot :
The result for serialization is:
<?xml version="1.0" encoding="utf-16"?> ....
But how can I controt which encoding is used ?? Now always UTF-16 is used. But I need ti use utf-8
How can i switch to utf-8 instead of using itf-16 ?
Peter
"Cerebrus" <zo*****@sify.com> wrote in message news:11**********************@y43g2000cwc.googlegr oups.com... Hi,
Try this : ------------------------------------------ ' I assume po is the object you want to serialize. Dim sw as New StringWriter() serializer.Serialize(sw, po) ' Get the serialized string Console.WriteLine(sw.ToString()) ------------------------------------------ HTH,
Regards,
Cerebrus.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Brian Reed |
last post by:
I have a class that I want to serialize to an XML string. I want the XML to serialize to utf-8 encoding. When I serialize to an XML file, the data looks great. When I try to serialize to a String...
|
by: grwalker |
last post by:
I have some classes that have the <Serializable()> attribute applied,
which of course by default serializes the class properties as elements.
What I would like to do is to be able to override this...
|
by: David Sworder |
last post by:
Hi,
I've created a UserControl-derived class called MyUserControl that is
able to persist and subsequently reload its state. It exposes two methods as
follows:
public void Serialize(Stream...
|
by: Dan |
last post by:
All I Am Attempting To Serialize An Object To An XML File.
Here Is The Code For That
public string SaveNewSurvey( MutualSurveyObject
mso_TempObject, int i_JobID )
{
string s_RootFileName;...
|
by: films |
last post by:
I understand the concept.
Serialization of a class will add all the sub-objects of the class to
the stream if there are also serializible.
So say I have:
class Author
{
|
by: Tim_Mac |
last post by:
hi,
i am able to serialize a normal generic List<> no problem. But when i
try to serialize a Dictionary<string,string>, i get an exception as
shown below:
"The type...
|
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...
|
by: Jinsong Liu |
last post by:
I have following 3 classes
public class MyMainClass
{
MyCollection<MyObject> m_oMyObjectCollection = null;
private string m_sID = string.Empty;
public MyCollection<MyObject> Collection
{
|
by: =?Utf-8?B?Qnlyb24=?= |
last post by:
When I try to serialize an instance of the LocationCell below (note Building
field) I get an error in the reflection attempt. If I remove the _Building
field it serializes fine. I tried renaming...
|
by: djidan |
last post by:
hi,
i am a newbe to c#, i'm trying to send en custom object from a client to a server, after reading a lot on the web ifound that i need to use:
BinaryFormatter, MemoryStream, and Serialize...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |