...I found this in my development group less than 12 hours after the previous post, helping to reaffirm my suprise that there are not more examples of the easy way...
using System; using System.Xml.Serialization; using System.IO;
using System;
using System.Xml.Serialization;
using System.IO;
...
public string ToXml()
{
XmlSerializer ser = new XmlSerializer(
typeof( MyClass)
);
//create a stream
MemoryStream ms = new MemoryStream();
XmlTextWriter xtw = new XmlTextWriter(
ms,
System.Text.Encoding.UTF8
ser.Serialize(xtw, this);
// read stream to string
ms.Position = 0;
StreamReader sr = new StreamReader(ms);
string Xml = sr.ReadToEnd();
ms.Close();
sr.Close();
return( Xml );
}
Remember Me
Theme design by Jelle Druyts
Pick a theme: BlogXP calmBlue Candid Blue dasBlog Discreet Blog Blue Elegante essence Just Html Mono Movable Radio Blue Movable Radio Heat orangeCream Portal Project84 Slate Sound Waves Tricoleur