XML Syntax

The XML syntax has the following rules:

1. - Any label must have a closing tag (</tag>)

<message> this is the content of the message </message>

2. - The tag names are case sensitive.

<message> and <Message> are different labels, because the second begins with a capital.

3. - The tags must be nested correctly.

We can not close a parent tag if we have not closed before all the labels of their children.

Example:

<message>     <from>John</from>     <to>Mark</to>     <title>Report</title>     <text>Create sales report </text> </message>

4. - Each XML document must have a single parent or root element.

For example, for the following XML, document root is <messages>, which of course must be closed at the end.

<?xml version = "1.0" encoding = "UTF-8"?> <messages>     <message>         <from>James</from>         <to>Peter</to>         <title>Meeting</title>         <text>Remember our meeting</text>     </message>     <message>         <from>John</from>         <to>Mark</to>         <title>Report</title>         <text>Create sales report</text>     </message> </messages>

5. - All attributes must be enclosed in double quotes.

All tags may or may not have attributes.

An attribute is used to provide additional information to the contents of a label.

For example, the tag may have an attribute <message> 'type' indicates the message type.

<message type="mail">         <from>James</from>         <to>Peter</to>         <title>Meeting</title>         <text>Remember our meeting</text> </message>

6. - Do not use special characters.

You can not use the characters (< , >, &, ', ") at any value of the labels.

7. - Comments

Comments can be put anywhere in an XML document

Sample comments:

<!-- This is a comment -->