Understanding XML DTD with a sample code

An XML DTD is the document that defines how an XML document should look like. You can think of a DTD as an outline or a rule that should be followed in creating an XML document. The number of nodes and child nodes are defined for a particular tag in an XML document.

If you know how to create or read a DTD document then you can create an XML document based on that DTD. Knowledge on DTD would help you to find out what went wrong in an XML document if that document fails the validation. Consider the following DTD document:

<!ELEMENT freeSoftware ( download+ ) >
<!ELEMENT download ( productName, link+ ) >
<!ELEMENT productName ( #PCDATA ) >
<!ELEMENT link ( #PCDATA ) >

In the above code in the DTD, you can understand that the XML document created based on that would have one or more <download> elements. Each of these <download> element would have one <productName> child node and one or more <link> child node. The '+' sign indicates that the node can be present one or more times.


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.