Valid XML Documents

Most XML browsers will check your document to see if it is well formed. Some of them can also check whether it's valid. An XML document is valid if there is a document type definition (DTD) or XML schema associated with it, and if the document complies with that DTD or schema.

A document's DTD or schema specifies the correct syntax of the document, as we'll see in Chapter 3, “Valid Documents: Creating Document Type Definitions,” for DTDs and Chapter 5, “Creating XML Schemas,” for schemas. For example, DTDs can be stored in a separate file, or they can be stored in the document itself using a <!DOCTYPE> element. Here's an example in which I add a <!DOCTYPE> element to the greeting XML document we developed earlier:

Listing ...

Get Real World XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.