xml XML document with an external DTD


In external DTD elements are declared outside the XML file. They are accessed by specifying the system attributes which may be either the legal .dtd file or a valid URL. To reference it as external DTD, the standalone attribute in the XML declaration must be set as no.

An XML that describes a note that contains property to, from and the message is given below.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE note SYSTEM "note.dtd">
  <message>Stack Overflow is awesome</message>

External DTD for the above XML, note.dtd is given below

<!DOCTYPE note [
<!ELEMENT note (to,from,message>
<!ELEMENT message (#PCDATA)>