There are nine basic rules for building good XML:
- All XML must have a root element. [This element begins and ends your entire document.]
- All elements must have an opening tag and a closing tag.
- All elements must be properly nested. [Close your elements in the reverse order you opened them. I.e., close the most recently opened element before closing elements opened earlier.]
- Element names must not start with a number, a punctuation mark, or the string XML.
- Element names are case sensitive.
- Element names cannot contain spaces. [If you want to use multiple words in the element name, use camelCase: <placeName>.]
- Attribute values must appear within quotation marks (“”).
- Don’t type spaces unless they are meaningful. [Space is significant. If you type a space, the processor will usually retain it.]
- Optional: avoid HTML tags. [Some XML languages do adopt HTML tags. TEI-XML uses <hi>, <p>, and <li>.
A markup language that conforms to these rules is well formed … or XML-compliant.