XML rules

- XML document must contain one or more elements
- There is exactly one element, called the root, or document element, no part of which appears in the content of any other element
- The name in an element's end-tag must match the element type in the start-tag. Names are case-sensitive
- If the start-tag is in the content of another element, the end-tag is in the content of the same element. More simply stated, the elements, delimited by start- and end-tags, nest properly within each other
- The end of every element that begins with a start-tag must be marked by an end-tag containing a name that echoes the element's type as given in the start-tag. The text between the start-tag and end-tag is called the element's content. An element without content can take a special form: <name/> . The slash before > substitutes the end tag
- Element names can contain letters, digits, hyphens, underscores, colons, or full stops
- A colon can be used only in a special case where it separates so called namespace. Element names starting with xml, XML or other combination of cases of this string are reserved for the standard
- Names cannot start with a number or punctuation character
- Names cannot start with the letters xml (or XML, or Xml, etc)
- Names cannot contain spaces
- Element names starting with xml, XML or other combination of cases of this string are reserved for the standard
- An element can have none, one or several attributes. Permitted characters are the same as for element names. The name of attribute is separated from its value by =. The attribute value must be given inside apostrophes '...' or double-quotes "..." . If an apostrophe or double-quote is used in the attribute value the opposite delimiter must be used
- Characters < and & cannot be used in text as they are used in markup. If these characters are needed < must be used insted of < and & instead of &
- Characters >, " , and ' can be also substituted by > , " and ' , respectively
- Comments may appear anywhere in a document outside other markup. An XML processor may, but need not, make it possible for an application to retrieve the text of comments. The string "--" (double-hyphen) must not occur within comments. <! -- This is a comment -- >
- Processing instructions (PIs) allow documents to contain instructions for applications
- CDATA sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string "<![CDATA[" and end with the string "]]>". The string ']]>' must not occur inside CDATA section
- XML documents may, and should, begin with an XML declaration which specifies the version of XML being used