Creating XML Taxonomies - What's Next?
(Page 4 of 4 )
Now we have the basic parent fields for our taxonomy. The next step is to further develop these fields and figure out the child fields. Technically, we’ve already done most of this work. Let’s go ahead and show how our XML document might look. Child tags will be denoted by indentation.
<?xml version=”1.0” standalone=”Yes”?> //declaration, explained in a later article
<albums> //Root
<album> //Parent
<albuminfo> //Child of album
<artist> Rolling Stones </artist> //Child of albuminfo
<genre> Rock and Roll <genre> //Child of albuminfo
<format> CD </format> //Child of albuminfo
<price> $19.95 </price> //Child of albuminfo
<uniqueID> 00100 </uniqueID> //Child of albuminfo
<label> Empire Records </label> //Child of albuminfo
<length> //Child with no content
<release> Oct 10, 2007 </release> //Child of albuminfo
</albuminfo>
<customerinfo>
<first> Mick </first>
<last> Mars </last>
<address>
<email>mickmars@email.com</email>
<phone> 555-5555 </phone>
</customerinfo>
<salesinfo>
<uniqueID> 00100 </uniqueID>
<price> 19.95 </price>
<coupon>
<shipping> $2.00 </shipping>
<totalPrice> $21.95 </shipping>
<date> 10/11/2008 </date>
<type> Retail </type>
</salesinfo>
</album>
</albums>
As you can see from above, albums is the root and we leave the root tag open until the end of the document, where we close it. Next we have album as a parent. Albuminfo is a child of album, and the fields: artist, genre, format, price, uniqueID, label, length, and release are all children of albuminfo. We leave albuminfo open until we list all of the child nodes, and then we close albuminfo. This continues with customerinfo and salesinfo. Finally, we close the album tag, and then the albums root.
This is a pretty simplistic view of an XML document. In reality they are much more complex. For instance, this setup shows no attributes. We will delve into that in a later article.
Final Words
In our next article we are going to begin using HTML and XHTML and learn how to validate our XML documents. We will look at the advantages of HTML and XHTML and truly begin to work with XML in real life scenarios.
Thank you for reading. If you have any questions or comments, please feel free to leave them.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |