How to use DTD in XML

In this article you will learn how to use DTD in XML.
  • 1810


DTD  stands for (Document Type Definition), and building block of xml. Or  we can say it bind the xml element and attributes. It can be declare inside of xml document  or external  interface also. It define the rule for creating xml document. For this xml look like a well format, generally  it is created in top of xml document . DTD  also specifies that an xml can contain what elements  in which order, and  how the elements should be organized inside the other. It specifies that an element can contain what attributes.

This is example of DTD

<?xml version="1.0" encoding="utf-8" ?>

<!DOCTYPE note [

  <!ELEMENT note (to,from,heading,body)>


  <!ELEMENT from (#PCDATA)>

  <!ELEMENT heading (#PCDATA)>

  <!ELEMENT body (#PCDATA)>



  <to> how are you </to>

  <from>alok </from>

  <heading>Reminder me</heading>

  <body>Don't forget me this year</body>


Output of above written code is


Further Readings

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

© 2020 DotNetHeaven. All rights reserved.