XDeclaration

In this chapter you will learn:

  1. Creating a Declaration

Creating a Declaration

using System;//j av a 2s.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 XDeclaration("1.0", "UTF-8", "yes"),
                new XElement("BookParticipant"));

        Console.WriteLine(xDocument);
    }
}

Next chapter...

What you will learn in the next chapter:

  1. Get Encoding, Version and standalone from XML declaration
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