Well-Formed XML

In a Nutshell:

Well-formed XML conforms to these four rules, determined by the World Wide Web Consortium ( W3C):

  1. An XML document consists of a root element, optionally preceded by a prolog and followed by miscellaneous content (which simply allows white space to exist there);
  2. XML elements have either
    • An opening tag, data, and a closing tag; or
    • A single self-closing tag.
  3. XML tags begin and end with angle-brackets < > and have a name.
    • Opening tags may have attributes;
    • Closing tags have a forward slash immediately after the first angle-bracket </;
    • Self-closing tags have a forward slash immediately before the second angle-bracket />
  4. Elements can contain other elements, but they cannot overlap. The first element to open is the last to close.

 

Check yourself!