.Net application development specialists
asp.net, c#, vb.net, html, javascript, jquery, html, xhtml, css, oop, design patterns, sql server, mvc and much more
contact: admin@paxium.co.uk

Paxium is the company owned by myself, Dave Amour and used for providing IT contract development services including


  • Application development - Desktop, Web, Services - with Classic ASP, Asp.net WebForms, Asp.net MVC, Asp.net Core
  • Html, Css, JavaScript, jQuery, React, C#, SQL Server, Ado.net, Entity Framework, NHibernate, TDD, WebApi, GIT, IIS
  • Database schema design, implementation & ETL activities
  • Website design and hosting including email hosting
  • Training - typically one to one sessions
  • Reverse Engineering and documentation of undocumented systems
  • Code Reviews
  • Performance Tuning
  • Located in Cannock, Staffordshire
Rugeley Chess Club Buying Butler Cuckooland Katmaid Pet Sitting Services Roland Garros 60 60 Golf cement Technical Conformity Goofy MaggieBears Vacc Track Find Your Smart Phone eBate Taylors Poultry Services Lafarge Rebates System Codemasters Grid Game eBate DOFF

XML Encode in C#

Ever wanted to have a little method to encode xml content?  You know when you have a < but you want it to appear as &lt;  - that kind of thing.

Well We can leverage existing base classes to achieve this quite easily as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
 
namespace XmlEncode
{
    class Program
    {
        static void Main(string[] args)
        {
            string text1 = "2 & 4";
            string text2 = "2 < 4";
 
            Console.WriteLine(XMLEncode(text1));
            Console.WriteLine(XMLEncode(text2));
 
            Console.Read();
        }
 
        public static string XMLEncode(string val)
        {
            if (val.Length == 0)
            {
                return string.Empty;
            }
 
            XmlDocument xmldoc = new XmlDocument();
 
            XmlElement element = xmldoc.CreateElement("E");
 
            element.InnerText = val;
 
            return element.InnerXml;
        }
    }
}


And thats it!  Any comments welcome as always.