XML DTD



XML DTD :

  • DTD stands for Document Type Definition.
  • A DTD allows you to create rules for the elements within your XML documents.
  • Although XML itself has rules, the rules defined in a DTD are specific to your own needs.

Syntax

<!ELEMENT element_name content_model>

Example

<!ELEMENT tutorials “Wikitechy XML Tutorial”>

Internal DTD

  • The following example demonstrates Internal DTD.
    • Doctype with DTD will be placed inside the XML
    • Elements and tags will be accessed by the xml from DTD.

Syntax

<!DOCTYPE root-element [element-declarations]>

root-element is the name of root element and element-declarations is where you declare the elements.

XML DTD

Learn XML - XML tutorial - XML DTD - XML examples - XML programs

External DTD

  • The following example demonstrates External DTD.
    • Doctype with DTD will be placed as a separate file.
    • Elements and tags will be accessed by the xml file from DTD file.

Syntax

<!DOCTYPE root-element SYSTEM "file-name">

file-name is the file with .dtd extension

XML External DTD

Learn XML - XML tutorial - XML External DTD - XML examples - XML programs



Related Searches to XML DTD