CSharp - Creating a Document Type and Adding It to a Document

Description

Creating a Document Type and Adding It to a Document

Demo

using System;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;

class Program/*from  ww  w  . jav  a  2s. c om*/
{
    static void Main(string[] args){
        XDocument xDocument = new XDocument();
        
        XDocumentType documentType =
          new XDocumentType("Books", null, "Books.dtd", null);
        
        xDocument.Add(documentType, new XElement("Books"));
        
        Console.WriteLine(xDocument);
    }
}

Result

Related Topic