Cheat Sheet

XML For Dummies

XML is a markup language that builds web pages. Before you start using XML, study the difference between a valid and well-formed document, how to create DTD (Document Type Definition) elements, and basic schema declarations to build an XML document. You'll also want to understand regularly used reserved characters, as well as which web browsers best support XML and style sheets.

Valid Versus a Well-Formed XML Document

In XML, a valid document must conform to the rules in its DTD (Document Type Definition) or schema, which defines what elements can appear in the document and how elements may nest within one another. If a document isn’t well-formed it doesn’t go far in the XML world so you need to play by some very basic rules when creating an XML document. A well-formed document must have these components:

All beginning and ending tags match up. In other words, opening and closing parts must always contain the same name in the same case: <tag> . . . </tag> or <TAG> . . . </TAG>, but not <tag> . . . </TAG>.

All attribute values occur within single or double quotation marks: <elementid="value"> or <element id='value'>.

Rules for Creating Document Type Definition, or DTD, Elements

Basically, you prepare and use a Document Type Definition (DTD) to add structure and logic, making it easier to ensure that all essential features are present — in the right order — in your XML document. You may develop many rules in your DTD that control how elements can be used in an XML document.

Symbol

Meaning

Example

#PCDATA

Contains parsed character data or text

<element (#PCDATA)>

#PCDATA, element-name

Contains text and another element; #PCDATA is always listed first in a rule

Common Reserved Characters in XML

Some entities are reserved for internal use in XML and need to be replaced with character references in your content. These five commonly used internal entities are already defined as part of XML and ready for you to use:

Character

Reference

<

&lt;

>

&gt;

&

&amp;

'

&apos;

"

&quot;

Browser Support for XML and Style Sheets

Web browser support for XML and style sheets — CSS and XSLT — is varied and sometimes less-than reliable. Research your options for web browsers so you know which browsers support which requirements and you choose how to use XML and web browsers in your XML solution.