471,327 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

Serialize

Is it possible to "Serialize" a class to xml into a string or XmlDocument
without having to create a disk file?

Thanks in advance.

Dec 19 '05 #1
2 1016
KJ
Sure:
public string XmlSerialize()
{
XmlSerializer mySerializer = new XmlSerializer(this.GetType());
MemoryStream ms = new MemoryStream();
mySerializer.Serialize(ms, this);
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
return sr.ReadToEnd();
}

And this is nice and generic.

Dec 19 '05 #2
XmlSerializer.Serialize() has overloads that take streams and such. Is that
what you are talking about?

"David" <Co*********@AdsorptionProcessModeling.com> wrote in message
news:LfGpf.57151$WH.53556@dukeread01...
Is it possible to "Serialize" a class to xml into a string or XmlDocument
without having to create a disk file?

Thanks in advance.


Dec 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Sworder | last post: by
10 posts views Thread by Dan | last post: by
1 post views Thread by js | last post: by
4 posts views Thread by =?Utf-8?B?Qnlyb24=?= | last post: by

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.