Create CData - CSharp System.Xml

CSharp examples for System.Xml:CData

Description

Create CData

Demo Code


using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from   w  w w .j a  va  2 s. co m

public class Main{
        public static void CreateCData(this XmlElement parent, string elemName, string content)
        {
            XmlElement element = parent.CreateChildElement(elemName);
            XmlCDataSection cdata = element.OwnerDocument.CreateCDataSection(content);
            element.AppendChild(cdata);
        }
        public static XmlElement CreateChildElement(this XmlElement parent, string elemName)
        {
            XmlElement element = parent.OwnerDocument.CreateElement(elemName);
            parent.AppendChild(element);
            return element;
        }
}

Related Tutorials