Add first to XDocument in CSharp
Description
The following code shows how to add first to XDocument.
Example
using System;/*from ww w.j a v a 2s.co m*/
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using System.IO;
public class MainClass{
public static void Main(string[] args){
XDocument NewDoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"),
new XElement("Root", "MyDoc"));
NewDoc.AddFirst(new XDocumentType(
"MyDocType", "MyPubID",
"MySysID", "ThisInternalSubset"));
Console.WriteLine(NewDoc);
}
}
The code above generates the following result.