[thelist] The truth about XML
Simon Willison
cs1spw at bath.ac.uk
Sat Oct 4 08:17:26 CDT 2003
Tim Burgan wrote:
> At the risk of looking like a fool .. I'll ask this question on a topic where I
> need a little clarification.
>
> What is the difference between XML and XHTML, in my current understanding -
> aren't they the same thing?
>
> Can you please give me an example of each.
They're definitely not the same thing. You can think of it like this:
XHTML is a subset of XML, but XML is not a subset of XHTML.
XML is simply a set of rules for defining a markup language. The
following snippets are all valid XML documents:
<person>
<name>Simon</name>
<url>http://simon.incutio.com/</url>
</person>
or...
<item rdf:about="http://simon.incutio.com/archive/2003/10/03/mfaInSoftware">
<title>Master of Fine Arts in Software</title>
<description><p>Richard P. Gabriel's proposal for a ...
</description>
<link>http://simon.incutio.com/archive/2003/10/03/mfaInSoftware</link>
<dc:subject>Uni Life</dc:subject>
<dc:date>2003-10-03T23:50:11</dc:date>
<dc:creator>Simon Willison</dc:creator>
</item>
or...
<config>
<option name="showlinks" value="yes" />
<option name="bigheadings" value="no" />
</config>
Note that all of the above examples have similar syntax, using <tags>
and attributes properly nested within each other, but the actual tags
used (and their meanings) are completely different. XML is the set of
rules for what tags should look like and how they should be nested - it
doesn't cover what tags you are allowed to use.
The technical term for a specification that describes the set of
available XML tags (and how they can be nested) is an "XML application".
XHTML is an XML application that specifies how XML can be used to
desribe a web page - XHTML documents look very similar to HTML
documents, except they follow the rules of XML (which include things
like all tags must have a matching closing tag, attributes must be
quoted, tags must be nested properly and there must be a root tag for
the overall document).
For an example of XHTML, view source on my site http://simon.incutio.com/
So the difference between XHTML and XML is that XML is just one of a
potentially infinite number of XMl applications. XML describes the basic
rules, XHTML expands on these by specifying allowed tags and attributes
and what they actually mean.
I hope that's a clear enough explanation,
Simon Willison
http://simon.incutio.com/
More information about the thelist
mailing list