Valid Versus a Well-Formed XML Document - dummies

Valid Versus a Well-Formed XML Document

By Lucinda Dykes, Ed Tittel

Part of XML For Dummies Cheat Sheet

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>.

  • Empty elements follow special XML syntax, for example, <empty_element/>.

  • All attribute values occur within single or double quotation marks: <element id=”value”> or <element id=’value’>.