﻿{"id":112,"date":"2009-08-15T20:40:12","date_gmt":"2009-08-15T18:40:12","guid":{"rendered":"http:\/\/www.idwaikat.me\/?p=112"},"modified":"2009-08-16T23:39:12","modified_gmt":"2009-08-16T21:39:12","slug":"object-to-xml-serialization-in-net","status":"publish","type":"post","link":"http:\/\/www.idwaikat.me\/?p=112","title":{"rendered":"Object to XML Serialization in .NET"},"content":{"rendered":"<p>Hi all.<\/p>\n<p>Today I read a topic related to XML, Serializing and Deserializing object, I enjoyed it because it provides an awesome way to convert objects (like classes) to XML. Before today, I used for loops and tags to build XML file, which needs alot of time and takes much of work when I need to modify the XML.<\/p>\n<p>In this post, I will make a simple example to introduce this issue, I&#8217;ll use C#, if you need any help in VB.NET please send to me.<\/p>\n<p>I will not talk about XML, I suppose you know whats the benefits and drawbacks of XML, but I will mention two important things when you need to serialize class to XML:<!--more--><\/p>\n<ul>\n<li>XML serialization can serialize only public data. You cannot serialize private data<\/li>\n<li>You cannot serialize object graphs; you can use XML serialization only on objects.<\/li>\n<\/ul>\n<p>The following example is about Person class with some public variables, one of the is an enumerator; Gender:<\/p>\n<p>\u00a0<\/p>\n<div><span style=\"font-size: x-small; color: #0000ff;\"><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><\/span><span style=\"font-size: x-small;\">\u00a0<\/span><span style=\"font-size: x-small; color: #0000ff;\">enum<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">Gender <\/span><span style=\"font-size: x-small;\">{ Male,Female}<\/span><\/div>\n<p><span style=\"font-size: x-small;\">To create a serilizable class you must add <strong>Serializable<\/strong> attribute for the class, and use an <strong>empty constructor<\/strong>, below is the class for Person:<\/span><\/p>\n<p>\u00a0<span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">[<\/span><\/span><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #2b91af;\">Serializable<\/span><span style=\"font-size: x-small;\">]<br \/>\n<\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #0000ff;\">class<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<br \/>\n<\/span><span style=\"font-size: x-small;\">{<br \/>\n<\/span><span style=\"font-size: x-small; color: #0000ff;\">\u00a0\u00a0 public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #0000ff;\">string<\/span><span style=\"font-size: x-small;\"> Name;<br \/>\n\u00a0\u00a0 <\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #0000ff;\">string<\/span><span style=\"font-size: x-small;\"> Address;<br \/>\n\u00a0\u00a0 <\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">Gender<\/span><span style=\"font-size: x-small;\"> Gender;<br \/>\n\u00a0\u00a0 <\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">DateTime<\/span><span style=\"font-size: x-small;\"> RegistrationDate;<br \/>\n\u00a0\u00a0 <\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #0000ff;\">double<\/span><span style=\"font-size: x-small;\"> Mark;<\/span><\/span><\/span><\/span><\/p>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0\u00a0 <\/span><span style=\"font-size: x-small; color: #0000ff;\">public<\/span><span style=\"font-size: x-small;\"> Person()<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"font-size: x-small;\">{<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/>\n}<\/span><\/span><\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><\/span><\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><\/span><\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\">\u00a0<span style=\"font-size: x-small;\">Now we will create serialize function, which saves the values of Person class object to XML file (Not that we are woking on ASP.NET &#8211; C#)<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Create an instance of Person class<br \/>\n<\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<\/span><span style=\"font-size: x-small;\"> person = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<\/span><\/span><\/span><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">();<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/span><\/span><\/span><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Create File using FileStream<br \/>\n<\/span><span style=\"font-size: x-small;\">System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileStream<\/span><span style=\"font-size: x-small;\"> fs = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileStream<\/span><span style=\"font-size: x-small;\">(Server.MapPath(<\/span><span style=\"font-size: x-small; color: #a31515;\">&#8220;~\/SerializedObject.XML&#8221;<\/span><span style=\"font-size: x-small;\">),System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileMode<span style=\"font-size: x-small;\"><span style=\"color: #000000;\">.Create);<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/span><\/span><\/span><\/span><\/div>\n<p>\u00a0<\/p>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Initialize it<br \/>\n<\/span><span style=\"font-size: x-small;\">person.Name = <\/span><span style=\"font-size: x-small; color: #a31515;\">&#8220;Ibrahim&#8221;<\/span><span style=\"font-size: x-small;\">;<br \/>\nperson.Gender = <\/span><span style=\"font-size: x-small; color: #2b91af;\">Gender<\/span><span style=\"font-size: x-small;\">.Male;<br \/>\nperson.Address = <\/span><span style=\"font-size: x-small; color: #a31515;\">&#8220;Palestine&#8221;<\/span><span style=\"font-size: x-small;\">;<br \/>\nperson.RegistrationDate = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> <\/span><span style=\"font-size: x-small; color: #2b91af;\">DateTime<\/span><span style=\"font-size: x-small;\">(2009, 1, 1);<br \/>\nperson.Mark = 94.5;<\/span><\/span><\/span><\/div>\n<p>\u00a0<\/p>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Create an XmlSerializer object to perform the serialization<br \/>\n<\/span><span style=\"font-size: x-small;\">System.Xml.Serialization.<\/span><span style=\"font-size: x-small; color: #2b91af;\">XmlSerializer<\/span><span style=\"font-size: x-small;\"> xs = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> System.Xml.Serialization.<\/span><span style=\"font-size: x-small; color: #2b91af;\">XmlSerializer<\/span><span style=\"font-size: x-small;\">(<\/span><span style=\"font-size: x-small; color: #0000ff;\">typeof<\/span><span style=\"font-size: x-small;\">(<\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<\/span><\/span><\/span><span style=\"font-size: x-small;\">));<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Use the XmlSerializer object to serialize the data to the file<\/span><\/span><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\">xs.Serialize(fs, person);<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Close the file<br \/>\n<\/span><span style=\"font-size: x-small;\">fs.Close();<\/span><\/span><\/span><\/div>\n<p>\u00a0<\/p>\n<p>The output\u00a0XML is like this:<\/p>\n<div class=\"e\"><span style=\"color: #0000ff;\"><span class=\"m\">&lt;?<\/span><span class=\"pi\">xml version=&#8221;1.0&#8243; <\/span><span class=\"m\">?&gt;<\/span><\/span><\/div>\n<div class=\"e\"><span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Person<\/span><\/span><span class=\"ns\"><span style=\"color: #ff0000;\"> xmlns:xsi<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">=&#8221;<\/span><\/span><strong class=\"ns\"><span style=\"color: #ff0000;\">http:\/\/www.w3.org\/2001\/XMLSchema-instance<\/span><\/strong><span class=\"m\"><span style=\"color: #0000ff;\">&#8220;<\/span><\/span><span class=\"ns\"><span style=\"color: #ff0000;\"> xmlns:xsd<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">=&#8221;<\/span><\/span><strong class=\"ns\"><span style=\"color: #ff0000;\">http:\/\/www.w3.org\/2001\/XMLSchema<\/span><\/strong><span style=\"color: #0000ff;\"><span class=\"m\">&#8220;<\/span><span class=\"m\">&gt;<\/span><\/span><\/div>\n<div class=\"e\">\n<div>\n<div class=\"e\">\n<div style=\"margin-left: 1em; text-indent: -2em;\"><span class=\"b\"><strong><span style=\"color: #ff0000; font-family: Courier New;\">\u00a0<\/span><\/strong><\/span> <span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Name<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><span class=\"tx\"><strong>Ibrahim<\/strong><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Name<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<div class=\"e\">\n<div style=\"margin-left: 1em; text-indent: -2em;\"><span class=\"b\"><strong><span style=\"color: #ff0000; font-family: Courier New;\">\u00a0<\/span><\/strong><\/span> <span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Address<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><span class=\"tx\"><strong>Palestine<\/strong><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Address<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<div class=\"e\">\n<div style=\"margin-left: 1em; text-indent: -2em;\"><span class=\"b\"><strong><span style=\"color: #ff0000; font-family: Courier New;\">\u00a0<\/span><\/strong><\/span> <span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Gender<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><span class=\"tx\"><strong>Male<\/strong><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Gender<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<div class=\"e\">\n<div style=\"margin-left: 1em; text-indent: -2em;\"><span class=\"b\"><strong><span style=\"color: #ff0000; font-family: Courier New;\">\u00a0<\/span><\/strong><\/span> <span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">RegistrationDate<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><span class=\"tx\"><strong>2009-01-01T00:00:00<\/strong><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">RegistrationDate<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<div class=\"e\">\n<div style=\"margin-left: 1em; text-indent: -2em;\"><span class=\"b\"><strong><span style=\"color: #ff0000; font-family: Courier New;\">\u00a0<\/span><\/strong><\/span> <span class=\"m\"><span style=\"color: #0000ff;\">&lt;<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Mark<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><span class=\"tx\"><strong>94.5<\/strong><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Mark<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<div><span class=\"m\"><span style=\"color: #0000ff;\">&lt;\/<\/span><\/span><span class=\"t\"><span style=\"color: #990000;\">Person<\/span><\/span><span class=\"m\"><span style=\"color: #0000ff;\">&gt;<\/span><\/span><\/div>\n<\/div>\n<\/div>\n<p>\u00a0<\/p>\n<p><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span>The deserialization is very similar:<\/p>\n<p>\u00a0<span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small; color: #008000;\">\/\/Create an of Person class<br \/>\n<\/span><\/span><span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small; color: #2b91af;\">Person <\/span><\/span><\/span><span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small;\"><span style=\"color: #0000ff;\">person<\/span>;<span style=\"font-size: x-small;\">\ufffd<br \/>\n<\/span><\/span><\/span><\/span><\/p>\n<div><span style=\"font-size: x-small; color: #008000;\"><span style=\"font-size: x-small; color: #008000;\"><\/span><\/span><span style=\"font-size: x-small; color: #008000;\">\/\/ Create Filestream object to read the data from<br \/>\n<\/span><span style=\"font-size: x-small;\">System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileStream<\/span><span style=\"font-size: x-small;\"> fs = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileStream<\/span><span style=\"font-size: x-small;\">(Server.MapPath(<\/span><span style=\"font-size: x-small; color: #a31515;\">&#8220;~\/SerializedObject.XML&#8221;<\/span><span style=\"font-size: x-small;\">), System.IO.<\/span><span style=\"font-size: x-small; color: #2b91af;\">FileMode<\/span><span style=\"font-size: x-small;\">.Open);<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><span style=\"font-size: x-small; color: #008000;\">\/\/Create an XmlSerializer object to perform the deserialization<br \/>\n<\/span><span style=\"font-size: x-small;\">System.Xml.Serialization.<\/span><span style=\"font-size: x-small; color: #2b91af;\">XmlSerializer<\/span><span style=\"font-size: x-small;\"> xs = <\/span><span style=\"font-size: x-small; color: #0000ff;\">new<\/span><span style=\"font-size: x-small;\"> System.Xml.Serialization.<\/span><span style=\"font-size: x-small; color: #2b91af;\">XmlSerializer<\/span><span style=\"font-size: x-small;\">(<\/span><span style=\"font-size: x-small; color: #0000ff;\">typeof<\/span><span style=\"font-size: x-small;\">(<\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<\/span><span style=\"font-size: x-small;\">));<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/div>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span>\u00a0<\/div>\n<p><span style=\"font-size: x-small; color: #008000;\">\/\/ Use the XmlSerializer object to deserialize the data from the file<br \/>\n<\/span><span style=\"font-size: x-small;\">person = (<\/span><span style=\"font-size: x-small; color: #2b91af;\">Person<\/span><span style=\"font-size: x-small;\">)xs.Deserialize(fs);<span style=\"font-size: x-small;\">\u00a0<\/span><\/span><\/p>\n<div><span style=\"font-size: x-small;\"><span style=\"font-size: x-small;\">\u00a0<\/span><\/span><span style=\"font-size: x-small; color: #008000;\">\/\/Close the file<br \/>\n<\/span><span style=\"font-size: x-small;\">fs.Close();<\/span><\/div>\n<p>\u00a0<\/p>\n<p><span style=\"font-size: x-small;\">Tha&#8217;s all&#8230; for more details you may read <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.xml.serialization.xmlserializer.aspx\" target=\"_blank\">this <\/a>or <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/2baksw0z(VS.71).aspx\" target=\"_blank\">this <\/a>topic from MSDN.<\/span><\/p>\n<p><span style=\"font-size: x-small;\">Thanks for reading.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi all. Today I read a topic related to XML, Serializing and Deserializing object, I enjoyed it because it provides an awesome way to convert objects (like classes) to XML. Before today, I used for loops and tags to build XML file, which needs alot of time and takes much of work when I need<\/p>\n<div class=\"more-link\">\n\t\t\t\t <a href=\"http:\/\/www.idwaikat.me\/?p=112\" class=\"link-btn theme-btn\"><span>Read More <\/span> <i class=\"fa fa-caret-right\"><\/i><\/a>\n\t\t\t<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_expiration-date-status":"","_expiration-date":0,"_expiration-date-type":"","_expiration-date-categories":[],"_expiration-date-options":[]},"categories":[9],"tags":[11,12,25,22,14],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\r\n<title>Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"http:\/\/www.idwaikat.me\/?p=112\" \/>\r\n<meta property=\"og:locale\" content=\"en_US\" \/>\r\n<meta property=\"og:type\" content=\"article\" \/>\r\n<meta property=\"og:title\" content=\"Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat\" \/>\r\n<meta property=\"og:description\" content=\"Hi all. Today I read a topic related to XML, Serializing and Deserializing object, I enjoyed it because it provides an awesome way to convert objects (like classes) to XML. Before today, I used for loops and tags to build XML file, which needs alot of time and takes much of work when I need    Read More\" \/>\r\n<meta property=\"og:url\" content=\"http:\/\/www.idwaikat.me\/?p=112\" \/>\r\n<meta property=\"og:site_name\" content=\"Eng. Ibrahim Dwaikat\" \/>\r\n<meta property=\"article:published_time\" content=\"2009-08-15T18:40:12+00:00\" \/>\r\n<meta property=\"article:modified_time\" content=\"2009-08-16T21:39:12+00:00\" \/>\r\n<meta name=\"author\" content=\"admin\" \/>\r\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\r\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.idwaikat.me\/?p=112\",\"url\":\"http:\/\/www.idwaikat.me\/?p=112\",\"name\":\"Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat\",\"isPartOf\":{\"@id\":\"http:\/\/www.idwaikat.me\/#website\"},\"datePublished\":\"2009-08-15T18:40:12+00:00\",\"dateModified\":\"2009-08-16T21:39:12+00:00\",\"author\":{\"@id\":\"http:\/\/www.idwaikat.me\/#\/schema\/person\/7738daf850bf9025cb97d4e728b96e05\"},\"breadcrumb\":{\"@id\":\"http:\/\/www.idwaikat.me\/?p=112#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.idwaikat.me\/?p=112\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/www.idwaikat.me\/?p=112#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/www.idwaikat.me\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Object to XML Serialization in .NET\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.idwaikat.me\/#website\",\"url\":\"http:\/\/www.idwaikat.me\/\",\"name\":\"Eng. Ibrahim Dwaikat\",\"description\":\"Be better than expected\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.idwaikat.me\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.idwaikat.me\/#\/schema\/person\/7738daf850bf9025cb97d4e728b96e05\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.idwaikat.me\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/2.gravatar.com\/avatar\/8647144a952284a7cf0336a3632931a4?s=96&d=mm&r=g\",\"contentUrl\":\"http:\/\/2.gravatar.com\/avatar\/8647144a952284a7cf0336a3632931a4?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/www.idwaikat.me\"],\"url\":\"http:\/\/www.idwaikat.me\/?author=1\"}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.idwaikat.me\/?p=112","og_locale":"en_US","og_type":"article","og_title":"Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat","og_description":"Hi all. Today I read a topic related to XML, Serializing and Deserializing object, I enjoyed it because it provides an awesome way to convert objects (like classes) to XML. Before today, I used for loops and tags to build XML file, which needs alot of time and takes much of work when I need    Read More","og_url":"http:\/\/www.idwaikat.me\/?p=112","og_site_name":"Eng. Ibrahim Dwaikat","article_published_time":"2009-08-15T18:40:12+00:00","article_modified_time":"2009-08-16T21:39:12+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.idwaikat.me\/?p=112","url":"http:\/\/www.idwaikat.me\/?p=112","name":"Object to XML Serialization in .NET - Eng. Ibrahim Dwaikat","isPartOf":{"@id":"http:\/\/www.idwaikat.me\/#website"},"datePublished":"2009-08-15T18:40:12+00:00","dateModified":"2009-08-16T21:39:12+00:00","author":{"@id":"http:\/\/www.idwaikat.me\/#\/schema\/person\/7738daf850bf9025cb97d4e728b96e05"},"breadcrumb":{"@id":"http:\/\/www.idwaikat.me\/?p=112#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.idwaikat.me\/?p=112"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/www.idwaikat.me\/?p=112#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/www.idwaikat.me\/"},{"@type":"ListItem","position":2,"name":"Object to XML Serialization in .NET"}]},{"@type":"WebSite","@id":"http:\/\/www.idwaikat.me\/#website","url":"http:\/\/www.idwaikat.me\/","name":"Eng. Ibrahim Dwaikat","description":"Be better than expected","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.idwaikat.me\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.idwaikat.me\/#\/schema\/person\/7738daf850bf9025cb97d4e728b96e05","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.idwaikat.me\/#\/schema\/person\/image\/","url":"http:\/\/2.gravatar.com\/avatar\/8647144a952284a7cf0336a3632931a4?s=96&d=mm&r=g","contentUrl":"http:\/\/2.gravatar.com\/avatar\/8647144a952284a7cf0336a3632931a4?s=96&d=mm&r=g","caption":"admin"},"sameAs":["http:\/\/www.idwaikat.me"],"url":"http:\/\/www.idwaikat.me\/?author=1"}]}},"_links":{"self":[{"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/posts\/112"}],"collection":[{"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=112"}],"version-history":[{"count":10,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":118,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions\/118"}],"wp:attachment":[{"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.idwaikat.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}