RULES FOR XML SYNTAX DECLARATION
- If document contains a XML declaration then it must be first statement of the document.
- XML declaration is case – sensitive, where document begins with <?xml>. “xml” is in lower case.
- An HTTP protocol can override the value of encoding that you put in the XML declaration.
<?xml version="1.0" encoding="UTF-8"?>
SYNTAX RULES FOR ELEMENTS AND TAGS
Element Syntax: every XML-element must be closed either with begin or with finish components as shown below:
or just by this technique:
Nested elements: An XML element can contain other XML- elements as its child, but the children elements must not overlap it parent element. i.e., an end tag of an element must have the same tag name as that of the most recent unmatched start tag.
example for incorrect nested tags:
<?xml version="1.0"?> <author> <name>syntax definition </author> </name>
example for correct nested tags:
<?xml version="1.0"?> <author> <name>syntax definition </name> </author>
Root element: An XML document must have and can have only one root element. For example, following example is not a correct XML document, because both the a and b elements occur at the top level without a root element:
The correct form of XML document is:
<root> <a>...</a> <b>...</b> </root> or <a> <b>...</b> </a>
Case sensitivity: The tag names of XML-elements are case-sensitive. This means that the name of the starting and the ending elements should be exactly in the same case.
For example <Syntax> is different from <syntax>.