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 / .NET SDK / October 2004

Tip: Looking for answers? Try searching our database.

Xml Serialization question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cindy Liu - 07 Oct 2004 18:43 GMT
Hi,

I want to serialize an object into the memory buffer instead of into a file.
How do I do that?

All the examples I have seen are serializing into a file. In my case, I
don't have access to the hard disk. Can I serialize into the memory directly
using XmlSerializer?

Thanks in advance!!!
Cindy
Robert Jordan - 07 Oct 2004 19:21 GMT
Hi Cindy,

> I want to serialize an object into the memory buffer instead of into a file.
> How do I do that?
>
> All the examples I have seen are serializing into a file. In my case, I
> don't have access to the hard disk. Can I serialize into the memory directly
> using XmlSerializer?

using System.Xml;
using System.Xml.Serialization;
...

        public static string XmlSerializeToString(object data)
        {
            StringBuilder b = new StringBuilder();
            XmlSerializer x = new XmlSerializer(data.GetType());
            TextWriter w = new StringWriter(b);
            x.Serialize(w, data);
            w.Close();
            return b.ToString();
        }

bye
Rob
Cindy Liu - 07 Oct 2004 19:49 GMT
This is what I want! I found another way using MemoryStream. But your way is
the best!

Thanks!!!!!
Cindy

> Hi Cindy,
>
[quoted text clipped - 21 lines]
> bye
> Rob
agulko@pobox.com - 25 Oct 2004 18:25 GMT
Based on your example - how would I de-seralize from a string to an object ?

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.