Structure and syntax of XML
Syntax rules
Names of elements
- Names start with a letter or a underscore ("_").
- From the second position numbers are allawed and symbols such as "-" and ".".
- Names can not contain spaces.
- ":" is used for namespaces.
- Names can not start with "XML" or "xml" or any combination of "xml" in capital and lower letters.
- There cant be a space between "<" and the name.
All elements must have a end-tag
Unlike HTML where some tags (<hr>) don't have a end-tag, and for others you can leave it away. In XML a end-tag is obligated.XML-tags are case sensitive
The chose for copital, small letters or a mix is free. But the end-tag must be written exactly thesame as the start-tag.XML-tags must be nested correctly
<to><copie>me</to</copie> Not correct.
<to><copie>me</copie></to> Correct.Every XML-document must and can only have 1 root-tag
The first pair of tags is the root-tag. Within it everything else is nested.Attribute values must be within quotes.
XML-elements can have attributes (name="value"). But they have to be quotes.In XML white-spaces are respected
Unlike HTML, space, tabs and newlines in the of a element are stored.