Xml
Looking at some XML documents will help you have some sense of XML. We have collected some examples of the following XML data files for you:
An XML CD directory: This is my father's collection of CDs as XML data storage (I think it's all stale and boring titles).
An XML plant directory: This is a plant directory of plants, which is stored as an XML data store.
A simple food menu: This is a restaurant's breakfast recipe, as an XML data store.
Why is the XML display like this?
The XML document does not carry information about how to display the data. Since XML tags are "made" or "invented" by the author of an XML document, we do not know whether a tag such as < table> is a form that describes an HTML type, or a wooden table. There is no information on how to display data, and most browsers appear as XML documents.
In the next chapter, we'll look at some of the different solutions to display problems, including using CSS, XSL, JavaScript, and XML data islands.
displaying XML in CSS
You can use CSS to add display information to an XML document.
Use CSS to display your future XML file?
Will you use CSS to format future XML files? No, I don't think so. But we can still give it a try:
Take a look at this plain XML file: The CD directory, and then look at the format table: CSS file, last viewed: A CD directory formatted with CSS files.
Here is a fragment of the XML file, which adds a CSS format table reference:
< XML version= "1.0"?>
< Xml-stylesheet type= "text/css" href= "Cd_catalog.css"?>
< catalog>
< cd>
< Title>empire burlesque</title>
< Artist>bob dylan</artist>
< country>usa</country>
< company>columbia</company>
< price>10.90</price>
< year>1985</year>
</cd>
< cd>
< Title>hide your heart</title>
< Artist>bonnie tyler</artist>
< country>uk</country>
< Company>cbs records</company>
< price>9.90</price>
< year>1988</year>
</cd>
.
</catalog>
We don't think that formatting XML with CSS is a trend for the future web. Even though it might seem right to use CSS, we still think that using XSL to format XML would be a new standard (once the main browser supports it).
Will you use XML to create a future home page?
Will you use XML to write your future home page? No, I don't think you will. But we can try it: Write a homepage in XML. We don't think we'll create a home page in XML in the future. But we think that XHTML--as defined by XML--will do the job: Visit W3Schools ' XHTML School.