XDocument.Declaration gets or sets the XML declaration for this document.
using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass{
public static void Main(){
XDocument doc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("This is a comment"),
new XElement("Root", "content")
);
Console.WriteLine(doc.Declaration);
}
}
Related examples in the same category