Share via


Document Type Declaration Information

The XmlTextReader ensures that the DOCTYPE is well-formed. The XmlTextReader uses the document type definition (DTD) to check that the DOCTYPE is well-formed, but does not do any data validation using the DTD.

Note

In the .NET Framework version 2.0, the recommended practice is to create XmlReader instances using the XmlReaderSettings class and the Create method. This allows you to take full advantage of all the new features introduced in the .NET Framework 2.0. For more information, see Creating XML Readers.

Accessing DTD Information

When you call Read on a DOCTYPE node and check the NodeType property, the XmlNodeType.DocumentType enumeration value is returned. The PublicLiteral and the SystemLiteral are considered attributes. The attribute names are PUBLIC and SYSTEM. To retrieve the content of the attribute, use GetAttribute or another attribute accessing method. For example, if you have the following DOCTYPE:

<!DOCTYPE bookstore SYSTEM \\valid_url\books.dtd [<!ENTITY e 'ent'>]>

The following table lists what is returned for the GetAttribute method and Value property.

Code

Value returned

myReader.GetAttribute("SYSTEM")

\\valid_url\books.dtd

myReader.Value

<!ENTITY e 'ent'>

See Also

Concepts

Reading XML with the XmlReader

Other Resources

Using the XmlReader Class