XML Versus HTML
HTML and XML are cousins. They draw off the same inspiration, SGML. They both identify elements in your page. They both use a very similar syntax. If you are familiar with HTML, XML will also feel familiar.
The big difference between HTML and XML is that HMTL has evolved into a markup language that describes the look, feel and action of a Web page. An <H1> is a headline that is displayed in a certain size, for example.
In contrast, XML doesn't describe how a page looks, how it acts or what it does. XML describes what the words in a document are. This is a critical distinction! While HTML combines structure and display, XML separates them. This means that XML documents are more portable and can be used in many different types of applications.
In the near future, we'll see both XML and HTML documents. Eventually, XML will probably replace HTML, or HTML will become an application of XML. But that doesn't mean you should toss out everything you know! In many ways, XML builds on HTML and if you know HTML, XML will be easier to work with.
Valid and Well-Formed XML
You'll sometimes hear an XML document referred to as a "valid" XML document or a "well-formed" XML document. This distinction touches on one of the nice things about XML.
When you used SGML, you had to create something call a Document Type Definition (DTD, for short) in order make the SGML document useful. DTDs were fairly complex and required a lot of work to create. They were one of the roadblocks to widespread use of SGML.
With XML you have an option. You can make a well-formed XML document by simply following the XML syntax rules. You don't have to create a separate DTD if you don't want to.
If you do create an set of rules—a DTD—and make your document conform to those rules, it is considered a valid XML document.
DTDs describe the structure of your document. We'll be discussing DTDs in detail later on. Right now, all you need to know is that the main difference between valid and well-formed XML is that valid XML refers to and conforms to a DTD and well-formed XML doesn't.