Create Declaration and Set Document's Declaration Property to It in CSharp

Description

The following code shows how to create Declaration and Set Document's Declaration Property to It.

Example


using System;//  w ww  . j  a v  a2s  .c  om
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
public class MainClass {
    public static void Main() {
        XDocument xDocument = new XDocument(new XElement("BookParticipant"));
        XDeclaration xDeclaration = new XDeclaration("1.0", "UTF-8", "yes"); 
        xDocument.Declaration = xDeclaration;
        Console.WriteLine(xDocument);
    }
}




















Home »
  C# Tutorial »
    XML »




Load Parse
Document
Element
Attribute
Namespace
Query
Save
Schema
Style