Encode Xml String - CSharp System.Xml

CSharp examples for System.Xml:XML String

Description

Encode Xml String

Demo Code


using System.Xml;
using System.Text.RegularExpressions;
using System.Text;
using System.IO;/*from   w w w  . j a  v  a  2  s  .  com*/
using System.Globalization;
using System;

public class Main{
        public static string EncodeXml(string xml)
        {
            return xml.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;").Replace("\"", "&quot;").Replace("'", "&apos;");
        }
}

Related Tutorials