DTD - Internal DTD

Internal DTD is a type of Document Type Definition that is written inside the XML document itself. It is defined within the <!DOCTYPE> declaration at the beginning of the XML file.

The main purpose of an internal DTD is to define the structure, elements, and attributes of the XML document in the same file. This makes the document self-contained and easy to understand.

Internal DTD is commonly used for small or simple XML documents where the rules do not need to be reused across multiple files. It is convenient when the XML structure is unique.

One advantage of internal DTD is that it is easy to edit and maintain, since both the XML data and its rules are present in one place.

However, internal DTD has limited reusability. If multiple XML documents require the same structure, the DTD must be duplicated in each file.

During validation, the XML parser checks the document against the internal DTD rules. Any mismatch in structure or attributes results in a validation error.

In summary, internal DTD is best suited for simple applications where portability and ease of management are more important than reuse.