Currently one of the projects I’m working on which uses private web services required me to send an XML version of an object that was being sent to the webservices.
I had not converted an object to XML format before but it is actually pretty easy with the XMLSerializer class.
Here is the code, all four lines of it:
XmlSerializer serializer = new XmlSerializer(typeof(IrishMQRiskInfo));
TextWriter textWriter = new StreamWriter(@”C:ProjectDirIrishMQObject.xml”);
I simply refreshed my project solution and the XML file was there for me to open up in Visual Web Developer.