Writing an XML DTD for an XML document

If you know the different components and the syntax of a DTD statement you can easily write it. before writing a DTD you should also know how your XML file elements should be present. To start with let us consider an example XML file where you need the root node to be <books>. This node can have one or more <book> node. For this you will be writing the DTD statement as,

<!ELEMENT books (book+) >

The plus sign indicates that the book node can be one or more. If the book node is to have two other child nodes named title and author. The author for a title can be more than one and at least one. So the DTD statement for that would be,

<!ELEMENT book (title, author+) >
<!ELEMENT title (#PCDATA) >
<!ELEMENT author (#PCDATA) >

The data that is present within the title tags and the author tags are text that is parsed by the parser. Hence they are written as #PCDATA.

If you have tools like XMLSpy you can generate a DTD from the XML document easily with the inbuilt tool for that purpose.



.

SetApp - 100 Apps for everything you ever wanted to do on Mac

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________




 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

“Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.”

Copyright - © 2004 - 2019 - All Rights Reserved.