Creating CData with XCData
using System; using System.Linq; using System.Xml.Linq; using System.Collections.Generic; class Program//w ww . j a v a2 s . c om { static void Main(string[] args){ XElement xErrorMessage = new XElement("HTMLMessage", new XCData("<H1>Invalid user id or password.</H1>")); Console.WriteLine(xErrorMessage); } }