Description

Updating the Document Type

Demo

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

class Program//  www. ja  v  a2  s.co m
{
    static void Main(string[] args){
              //  we will use this to store a reference to the DocumentType for later access.
             XDocumentType docType;
        
             XDocument xDocument = new XDocument(
               docType = new XDocumentType("Books", null,
                                           "Books.dtd", null),
               new XElement("Books"));
        
             Console.WriteLine("Before updating document type:");
             Console.WriteLine(xDocument);
        
             docType.Name = "MyBooks";
             docType.SystemId = "http://www.somewhere.com/DTDs/MyBooks.DTD";
             docType.PublicId = "-//DTDs//TEXT Book Participants//EN";
        Console.WriteLine("After updating document type:");
        Console.WriteLine(xDocument);
    }
}

Result

Related Topic