Internal DTD

Internal DTD

This is an XML document with a Document Type Definition:

<?xml version="1.0"?>
<!DOCTYPE note [
  <!ELEMENT note    (to,from,heading,body)>
  <!ELEMENT to      (#PCDATA)>
  <!ELEMENT from    (#PCDATA)>
  <!ELEMENT heading (#PCDATA)>
  <!ELEMENT body    (#PCDATA)>
]>

<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend</body>
</note>

Like the above example, if the DTD is to be included in your XML source file, it should be wrapped in a DOCTYPE definition with the following syntax:

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

In the above example, the DTD is interpreted like this:
!ELEMENT note (in line 2) defines the element “note” as having four elements: “to,from,heading,body”.
!ELEMENT to (in line 3) defines the “to” element  to be of the type “CDATA”.
!ELEMENT from (in line 4) defines the “from” element to be of the type “CDATA”
and so on…..

Share this post
[social_warfare]
External DTD
Value Proposition

Get industry recognized certification – Contact us

keyboard_arrow_up