ASP.NET XML Serialization

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”);

serializer.Serialize(textWriter, irishMQR);


I simply refreshed my project solution and the XML file was there for me to open up in Visual Web Developer.


Published by

Alan Feekery

Developer, Gamer, Musician, Cyclist and big Motorsport fan... enjoys the odd cup of coffee :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s