using System;using System.Xml.Linq;namespace ConsoleApplication1
{class Program{static void Main(string[] args){//寫入CDATA元素塊var doc = new XElement("Test",new XElement("User",new XAttribute("name", "chenxizhang"),new XCData("這是XCData的內容,可以包含特殊字符,例如< 或者 >")));Console.WriteLine("寫入CData元素");Console.WriteLine(doc.ToString());Console.WriteLine("讀取CData元素");Console.WriteLine(doc.Element("User").Value);}}
}