Add XML CData Node - CSharp System.Xml

CSharp examples for System.Xml:XML Node

Description

Add XML CData Node

Demo Code


using System.Text.RegularExpressions;
using System.Xml;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from   w ww. ja v  a 2  s.co m*/

public class Main{
        public static XmlNode AddCDataNode(XmlNode fathernode, string name, string content)
        {
            XmlDocument xdoc = fathernode.OwnerDocument;
            XmlNode snode = xdoc.CreateElement(name);

            XmlCDataSection CData = xdoc.CreateCDataSection(content);

            snode.AppendChild((XmlNode)CData);

            fathernode.AppendChild(snode);

            return snode;
        }
}

Related Tutorials