<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Introduction to XML Serialization</title>
	<atom:link href="http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/</link>
	<description>Software by Design</description>
	<lastBuildDate>Sat, 04 Feb 2012 10:08:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Eamon</title>
		<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/comment-page-1/#comment-8401</link>
		<dc:creator>Eamon</dc:creator>
		<pubDate>Thu, 20 May 2010 04:26:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/#comment-8401</guid>
		<description>Thank you  for sharing your response, and offering some solutions.,lucy</description>
		<content:encoded><![CDATA[<p>Thank you  for sharing your response, and offering some solutions.,lucy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AndrewS</title>
		<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/comment-page-1/#comment-4693</link>
		<dc:creator>AndrewS</dc:creator>
		<pubDate>Mon, 22 Jun 2009 01:42:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/#comment-4693</guid>
		<description>You could reduce the line count a little like this and retain the same logic:

public static void Serialize(string filename, T data)
{
	using ( TextWriter writer = new StreamWriter(filename) )
	{				
		new XmlSerializer(typeof(T)).Serialize(writer, data);
	}
}

public static T Deserialize(string filename)
{
	using ( TextReader reader = new StreamReader(filename) )
	{
		return (T)new XmlSerializer(typeof(T)).Deserialize(reader);
	}
}</description>
		<content:encoded><![CDATA[<p>You could reduce the line count a little like this and retain the same logic:</p>
<p>public static void Serialize(string filename, T data)<br />
{<br />
	using ( TextWriter writer = new StreamWriter(filename) )<br />
	{<br />
		new XmlSerializer(typeof(T)).Serialize(writer, data);<br />
	}<br />
}</p>
<p>public static T Deserialize(string filename)<br />
{<br />
	using ( TextReader reader = new StreamReader(filename) )<br />
	{<br />
		return (T)new XmlSerializer(typeof(T)).Deserialize(reader);<br />
	}<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C# Serializing Nullable Types by JohnnyCoder</title>
		<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/comment-page-1/#comment-2101</link>
		<dc:creator>C# Serializing Nullable Types by JohnnyCoder</dc:creator>
		<pubDate>Mon, 09 Jun 2008 19:56:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/#comment-2101</guid>
		<description>[...] Introduction to XML Serialization [...]</description>
		<content:encoded><![CDATA[<p>[...] Introduction to XML Serialization [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raghu</title>
		<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/comment-page-1/#comment-2096</link>
		<dc:creator>Raghu</dc:creator>
		<pubDate>Thu, 05 Jun 2008 01:25:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/#comment-2096</guid>
		<description>Hi, I have a similar requirement to serialize a Business object into XML and I thought of using the XmlSerializer as well. But after a bit of experimentation i realized that there is no way to serialize properties that are read-only and the only workaround i could find was to have an empty set accessor for these props. Another particular type that i had problem with was TimeSpan. The XmlSerializer had no idea of how to serialize a TimeSpan type. So that means all my classes that have a Timespan prop have to inherit from IXmlSerializable and they must implement the WriteXml function of this interface. Did anyone else ever had a similar situation ? Please let me know.

Thanks in anticipation.</description>
		<content:encoded><![CDATA[<p>Hi, I have a similar requirement to serialize a Business object into XML and I thought of using the XmlSerializer as well. But after a bit of experimentation i realized that there is no way to serialize properties that are read-only and the only workaround i could find was to have an empty set accessor for these props. Another particular type that i had problem with was TimeSpan. The XmlSerializer had no idea of how to serialize a TimeSpan type. So that means all my classes that have a Timespan prop have to inherit from IXmlSerializable and they must implement the WriteXml function of this interface. Did anyone else ever had a similar situation ? Please let me know.</p>
<p>Thanks in anticipation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mytymyky</title>
		<link>http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/comment-page-1/#comment-2080</link>
		<dc:creator>Mytymyky</dc:creator>
		<pubDate>Tue, 20 May 2008 20:59:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.alteridem.net/2007/08/13/introduction-to-xml-serialization/#comment-2080</guid>
		<description>I came across this page looking for a solution to the problem i&#039;m having and mentioned by Rob. Seems nullable types won&#039;t serialize as attributes, only as elements. I use ALOT of nullable types in my apps (not sure its the best way to go, but oh well) and I was trying to add them ás attributes instead of elements (to eliminate part of the tag&#039;s overhead) but I&#039;ve had no luck.

For now element&#039;s is how it will be...</description>
		<content:encoded><![CDATA[<p>I came across this page looking for a solution to the problem i&#8217;m having and mentioned by Rob. Seems nullable types won&#8217;t serialize as attributes, only as elements. I use ALOT of nullable types in my apps (not sure its the best way to go, but oh well) and I was trying to add them ás attributes instead of elements (to eliminate part of the tag&#8217;s overhead) but I&#8217;ve had no luck.</p>
<p>For now element&#8217;s is how it will be&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

