Well-Formedness

One of the major differences between XML and traditional HTML is the need for XML to be well formed. This means that unlike an HTML 4.0 document, an XML document must meet the following criteria:

  • It must have exactly one root element.

  • All elements must have matching start and end tags. This includes case. <H1> and </H1> match, but <H1> and </h1> do not.

  • All attributes must be in quotes. This is a common-sense rule, but HTML browsers often let authors get away without it.

  • All elements must nest properly. This means that when we see a start tag for one element, we should never see anything but a completely nested subelement or an end tag for the original element. For instance,

    <B>This is my <I>tiger</I>. He is ferocious.</B>
    

    is well ...

Get XML and Java™ from scratch 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.