How to serialize and deserialize an object in C# to a XML file

The following code shows how to serialize and deserialize an object in C# to a XML file.   Code using System; using System.Linq; using System.Collections.Generic; using System.Text; using System.IO; using System.Xml.Serialization; using System.Reflection; namespace MobileUI.BC { public class SerializationHelper<T> where T : class, new() { private string _fileName; public string …

Dynamically call a xslt template

You cannot call a xslt template like: <xsl:variable name="templateName" select="test"></xsl:variable> <xsl:call-template name="$templateName"> <xsl:template name="test"> </xsl:template> The clossed you can get to calling a xslt template dynamically is to use the <xsl:if or <xsl:choose based on a variable: <xsl:if test="$parameter1=$templateName"> <xsl:call-template name="test"></xsl:if>

You should use System.Security.SecurityElement.Escape in C# to escape special characters in XML and not System.Web.HttpUtility.HtmlEncode

You should use the function System.Security.SecurityElement.Escape and not the function System.Web.HttpUtility.HtmlEncode to escape special characters in XML if you don’t want the characters like éûÉ to be converted to &#233;&#251;&#201; which is permit able but not necessary en can result in long xml fields. var escapedXml = System.Security.SecurityElement.Escape(@"&<>’""’éûÉغ"); Console.WriteLine(escapedXml); // …