1.3.2. XML Tags
All XML elements must have a closing tag
With XML it is illegal to omit the closing tag. As you perhaps know in HTML some elements do not have a closing tag such as e.g. "<p>". The following code is legal in HTML:
Legal HTML CodeIn XML however, all elements have a closing tag, like this:
Legal XML CodeYou might have noticed from the previous example that the XML declaration (<?xml version="1.0" encoding="ISO-8859-1"?>) did not have a closing tag. This is not an error. The declaration is not a part of the XML document itself. It is not an XML element, and it therefore does not need a closing tag.
All XML elements must be properly nested
All XML elements must be properly nested within each other: you are not allowed to close an XML tag until other tags that are enclosed by that tag (so called childs), are closed as well:
Tag nestingXML tags are case sensitive
Opening and closing tags must be written with the same case. The tag <message> is different from the tag <Message>:
Tags are case sensitiveAll XML documents must have a root element
All XML documents must contain a single tag pair to define a root element. The name of the root element must appear once in an XML document. All other elements must be within this root element. All elements can have sub elements (child elements). Sub elements must be correctly nested within their parent element:
Root element and its childrenBy expanding our address example with the root element <person> we get the same structure as above (root, child, subchild).
Expanded address exampleComments in XML
The syntax for writing comments in XML is:
Comments in XML