XML Syntax Rules
The syntax rules of XML are very simple and logical. One can easily learn and use them.
- All XML Elements Must Have a Closing Tag
- All Tags are case sensitive.
- XML Elements must be properly nested.
- The XML document must have a root element.
- All the attribute values must be quoted.
- Comments are also permitted in XML using tag
- The white spaces in XML are not truncated
- The new line charecter is represented with Line Feed, the way it is in Unix environment.
XML Naming Rules
XML elements must follow these naming rules:
- Names can contain letters, numbers, and other characters.
- Names must not start with a number or punctuation character.
- Names must not start with the letters xml (or XML, or Xml, etc).
- Names cannot contain white spaces.
- Any name can be used, no reserved words are there.
XML Attributes
XML elements can have attributes in the tag, just like HTML. These attributes provide additional information about elements.
These attributes are used to provide additional information that is not part of the data.
XML attributes must be quoted, either single or double quotes can be used. If the attributes itself contains double quotes one can use single quotes.
Some of the problems in using attributes are:
- attributes cannot contain multiple values but elements can.
- attributes cannot contain tree structures but elements can.
- attributes are not easily expandable required for future changes.
Go to Step1 or Step2 or Step4