using System.Xml;
using System.Xml.Serialization;
using System.IO;
public string GetXMLFromObject(object o)
{
XmlSerializer XmlS = new XmlSerializer(o.GetType());
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
XmlS.Serialize(tw, o);
return sw.ToString();
}
using System.Xml.Serialization;
using System.IO;
public string GetXMLFromObject(object o)
{
XmlSerializer XmlS = new XmlSerializer(o.GetType());
StringWriter sw = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(sw);
XmlS.Serialize(tw, o);
return sw.ToString();
}
What is result?
ReplyDelete@Anonymous: You can pass an object to it and this method will return you a corresponding XML string.
ReplyDeleteI think @Anonymous was asking what the "result" variable inside the serialize method of XmlS on the second to last line was. I'd also like to know what that is.
ReplyDeleteOh guys, I'm really sorry. It was my mistake. Its not 'result'. It should have been the object 'o' which we receive as the input. I've modified the code.
ReplyDeleteThanks for putting answer.
ReplyDeleteHow do we go back?
ReplyDelete