XCData

In this chapter you will learn:

  1. How to crate CData section with XCData

Create a CData section

The following code creates an XCData Node and Passing It As the Value of a Created Element.

using System;//jav a 2  s. c  o  m
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XElement xErrorMessage = new XElement("HTMLMessage",new XCData("<H1>Invalid password.</H1>"));
        Console.WriteLine(xErrorMessage);
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Add an element that uses the namespace
Home » C# Tutorial » XML Linq
XDocument
Create XDocument
Add to XDocument
Parse XML file with XDocument
Load XML string with XDocument
XDocument Root
Query XML document with Linq
Save XML document
XDocument Serialize
XElement namespace
Adding attribute
XElement's NextNode
XAttribute
XAttribute value
XAttribute Properties
XAttribute namespace
XComment
XDeclaration
XML declaration
XCData
XNamespace