Microsoft Docs

XmlDtdNotation Class

Namespace: System.Xml

Assembly: System.Xml.dll

Summary

Represents an XML DTD notation. This class is used to expose DTD notation information via the XmlDocumentType class.

Syntax

public sealed class XmlDtdNotation : XmlNode

Remarks

XmlDtdNotation objects are read‑only. They are created by the XML parser when a DTD is read. The PublicId and SystemId properties provide the notation's public and system identifiers, respectively.

Properties

PublicIdGets the public identifier of the notation.
SystemIdGets the system identifier of the notation.
NameGets the name of the notation.
NodeTypeAlways returns XmlNodeType.Notation.
// Example: List all DTD notations in an XML file
using System;
using System.Xml;

class Program
{
    static void Main()
    {
        var doc = new XmlDocument();
        doc.Load("sample.xml"); // sample.xml contains a DOCTYPE with notations

        XmlDocumentType doctype = doc.DocumentType;
        if (doctype != null)
        {
            XmlNamedNodeMap notations = doctype.Notations;
            foreach (XmlNode node in notations)
            {
                var notation = (XmlDtdNotation)node;
                Console.WriteLine($"Notation: {notation.Name}");
                Console.WriteLine($"  PublicId: {notation.PublicId}");
                Console.WriteLine($"  SystemId: {notation.SystemId}");
            }
        }
        else
        {
            Console.WriteLine("No DOCTYPE found.");
        }
    }
}

See Also