By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,422 Members | 1,455 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,422 IT Pros & Developers. It's quick & easy.

Xml Serializer

P: n/a
I am trying to use XmlSerializer to serial an object into a String that I can manipulate. It seems that all the XmlSerializer only works with Streams. Does someone have a snippet of code that allows me to use XmlSerializer that I can get a "String" value back. Thanks for the Help.
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
BobL wrote:
I am trying to use XmlSerializer to serial an object into a String
that I can manipulate. It seems that all the XmlSerializer only
works with Streams. Does someone have a snippet of code that allows
me to use XmlSerializer that I can get a "String" value back. Thanks
for the Help.


I'm not familar with the XmlSerializer, but I think what you want is a
MemoryStream. Then you can use
System.Text.Encoding.Unicode.GetString(memstream.G etBuffer()) when you want
the string.

- Pete
Nov 15 '05 #2

P: n/a
"BobL" <an*******@discussions.microsoft.com> wrote in message
news:3A**********************************@microsof t.com...
I am trying to use XmlSerializer to serial an object into a String that I

can manipulate. It seems that all the XmlSerializer only works with
Streams. Does someone have a snippet of code that allows me to use
XmlSerializer that I can get a "String" value back. Thanks for the Help.

What object is it? If the object itself isn't serializeable, I don't think
it'll work anyway...
Nov 15 '05 #3

P: n/a
Have a go at:

XmlSerializer xser = new XmlSerializer (typeof (Participant));

StringBuilder sb = new StringBuilder ();
StringWriter sw = new StringWriter (sb);
xser.Serialize(sw, obj);

Console.WriteLine (sb.ToString ());
Console.ReadLine ();

Participant is just some class that is being serialized.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply

"BobL" <an*******@discussions.microsoft.com> wrote in message news:3A**********************************@microsof t.com...
I am trying to use XmlSerializer to serial an object into a String that I can manipulate. It seems that all the XmlSerializer only works with Streams. Does someone have a snippet of code that allows me to use XmlSerializer that I can get a "String" value back. Thanks for the Help.

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.