XML is a widespread notation standard made, basically, to share tables of information between different languages and applications using a simple text file.
For instance, imagine you have a table made in Excel—or any other similar application—named CHILDREN:
----------------------------
| ID | NAME | AGE |
----------------------------
| 1 | John | Five |
----------------------------
| 2 | Peter | Four |
----------------------------
| 3 | Mary | Seven |
----------------------------
and you want to export it to a database like Oracle, or to a PHP script, or to a FLASH application, etc. You need to create a standard format readable by all those different platforms. That standard is XML.
XML works with tags and parameters, just like HTML. The difference is that in XML you can make up your own tag names as you need them.
Look at the different ways of writing the table above using XML.
Using only tags, without parameters:
<?xml version="1.0" ?>
<children>
<child>
<id>1</id>
<name>John</name>
<age>Five</age>
</child>
<child>
<id>2</id>
<name>Peter</name>
<age>Four</age>
</child>
<child>
<id>3</id>
<name>Mary</name>
<age>Seven</age>
</child>
</children>
Using tags and a few parameters:
<?xml version="1.0" ?>
<children>
<child id="1">
<name>John</name>
<age>Five</age>
</child>
<child id="2">
<name>Peter</name>
<age>Four</age>
</child>
<child id="2">
<name>Mary</name>
<age>Seven</age>
</child>
</children>
Here I am using the parameter
id inside each
<child> tag to store the child's ID. The Name and Age are still stored within their own tags.
Using tags and more parameters:
<?xml version="1.0" ?>
<children>
<child id="1" name="John" age="Five" />
<child id="2" name="Peter" age="Four" />
<child id="3" name="Mary" age="Seven" />
</children>
Notice how, in this last example, since I am using parameters in the
<child> tags to store all my information—instead of adding more tags within—I can add a self-closing slash at the end of each
<child> instance.
Which method is the best one? Well, that's really up to you. Combine tags and parameters and see what best suits your needs.
By using XML you can easily store and exchange tables of information between multiple platforms.
Regarding its relationship with HTML, XHTML (the today's de-facto standard for HTML) allows XML markup inside the same HTML file. That is where the X comes from.