\n","url":"https://ez4code.com/snippets/xml-dtd-schema","keywords":"dtd, schema, validation","author":{"@type":"Person","name":"EZ4Code Team"},"publisher":{"@type":"Organization","name":"EZ4Code","logo":{"@type":"ImageObject","url":"https://ez4code.com/logo.png"}},"datePublished":"2024-01-01","dateModified":"2026-08-01","image":"https://ez4code.com/og-image.png"}
Document Type Definition for validation.
<?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ATTLIST note priority CDATA "normal">
]>
<note priority="high">
<to>Alice</to>
<from>Bob</from>
<heading>Reminder</heading>
<body>Don't forget the meeting</body>
</note>A DTD declares the allowed element structure, content model, and attributes for an XML document, embedded inline or referenced externally. #PCDATA means parsed character text, and the comma sequence enforces child order. DTDs predate XML Schema and cannot express data types, so XSD is preferred for new work.