Some XML DTD examples

Lots of working examples of XML and DTD are available in the internet. Let us consider a sample XML file of the format given under,

<?xml version="1.0" ?>
<videos>
<music>
<title>Video Title 1 </title>
<artist>Artist 1 </ artist >
</music>
< music >
<title>Video Title 2 </title>
< artist > Artist 2 </ artist >
< artist > Artist 3 </ artist >
</ music >
</ videos >

The above XML file has data related to music videos. In this XML file the root node is the <videos> and this can have any number of <music> elements. The <music> element can have a single <title> and any number of <artist> child nodes. For this structure you can write the DTD as,

<!ELEMENT videos ( music+ ) >
<!ELEMENT music ( title, artist+ ) >
<!ELEMENT title ( #PCDATA ) >
<!ELEMENT artist ( #PCDATA ) >

The ELEMENT word indicates that the word next to that is an element and the nodes of that particular element are given in the brackets. The + sign after the node in the bracket denotes that it could be any number of nodes. The #PCDATA indicates that it is a text node that has some value in it.


.

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.