XML rules

admin's picture
  1. XML document must contain one or more elements
  1. There is exactly one element, called the root, or document element, no part of which appears in the content of any other element
  1. The name in an element's end-tag must match the element type in the start-tag. Names are case-sensitive
  1. 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
  1. 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
  1. 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
  1. 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
  1. Characters < and & cannot be used in text as they are used in markup. If these characters are needed &lt; must be used insted of < and &amp; instead of &
  1. Characters >, " , and ' can be also substituted by &gt; , &quot; and &apos; , respectively
  1. 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 -- >
  1. Processing instructions (PIs) allow documents to contain instructions for applications
  1. 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
  1. XML documents may, and should, begin with an XML declaration which specifies the version of XML being used