XML

Extensible Markup Language or XML is a set of rules for encoding documents in machine-readable form. It looks a lot like HTML.

The diference between XML and HTML is that XML was designed to transport and store data, while HTML was designed to display data.

XML does not do anything. It merely holds information. It has no predefined tags. You invent your own tags in XML. You can give it meaningful names, or even not so meaningful or even confusing names if you so desire. But it is always better to give your tags meaningful names so it helps you code up things later rather than to confuse you.

XML is not a replacement for HTML, which can only use HTML tags. You can't make up HTML tags at will. But you can make up any tags you want in XML. As long as you are consistent and your file is "wellformed".

Wellformed-ness

 * 1) XML elements must be properly nested and not overlap
 * 2) * CORRECT: Romeo and Juliet Shakespeare
 * 3) * WRONG: Romeo and Juliet Shakespeare
 * 4) Empty elements may contain attributes
 * 5) * All the following are correct:
 * 6) You can define entities
 * 7) * 5 predeclared entities for symbols:
 * 8) * Define an entity in the DTD:  and then call it up with &copy;
 * 9) * You can have entitites inside entities as long as they are declared in order.
 * 1) * 5 predeclared entities for symbols:
 * 2) * Define an entity in the DTD:  and then call it up with &copy;
 * 3) * You can have entitites inside entities as long as they are declared in order.

Displaying XML

 * if you feed an xml doc straight to a browser, it will be rendered as raw xml text.
 * you can render it with css but then your xml must have this:

XPath
XPath may be used to compute values (strings, numbers, or boolean values) from the content of an XML document.


 * XPath tutorials
 * XPath tools

Example of an XML File
Here is an example of an XML file which I used to provide data for a flash slideshow viewer. It loaded in the headers, subheaders, and also the image file of the slide - straight into my waiting flash file. All the values were not set as fixed values in the flash file; instead they could be edited in this XML file by other people, and even non-developers/programmers were able to edit it in a simple text editor.

 

swf/ov_000.swf Overview first slide's subheader swf/ov_001.swf Overview second slide's subheader

swf/ov_002.swf Next Slide's header third slide's subheader



Instead of just putting in image, header, and subheader values, I could have made it such that the location of the textboxes could be defined in the xml sheet as well, or the speed of transition between slides. Many applications make use of XML to store data - from iPhoto to Openoffice. You can make up any values that you want into an XML sheet - it is virtually limitless what you could use it for.