I would probably use JSON instead of XML. Reason: it's easier to do the serialization and JSON serialization can handle a lot more types than
XmlSerialization can and the data produced is actually smaller as well.
* JsonConvert.Serialize()
* JsonConvertDeserialize< t >()
using Json.NET (which is default requirement on all web projects anyway).
+++ Rick ---
>Hi everybody,
>
>I found this code on stackoverflow
>
>
> public static string SerializeObject(this object obj)
> {
> System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
> System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(obj.GetType());
> using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
> {
> serializer.Serialize(ms, obj);
> ms.Position = 0;
> xmlDoc.Load(ms);
> return xmlDoc.InnerXml;
> }
> }
>
>and I am wondering what do you use normally? I am passing the XML to SQL Server and I need to parse it into the table and I am having troubles.
>
>My class is very simple
>
>InvoiceNo decimal
>Payment decimal
>
>and the object contains list of such objects.
>
>Thanks a lot in advance.
>
>UPDATE. The code seemed to work OK in my tests, although so far I tested the SP only. I haven't yet tested it from the application.