The syntax rules of XML are very simple and very strict. The rules are very easy to learn, and very easy to use. Because of this, creating software that can read and manipulate XML is very easy to do.
An Example XML Script
XML documents use a self-describing and simple syntax.
The first line in the document—the XML declaration—defines the XML version and the character encoding used in the document.
In this case the document conforms to the 1.0 specification of XML and uses the ISO-8859-1 (Latin-1/West European) character set.
The next line describes the root element of the document: <note>
.
The next 4 lines describe four child elements of the root (to
, from
, heading
, and body
):
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
And finally the last line defines the end of the root element: </note>
.
- XML tags are case sensitive.
Unlike HTML, XML tags are case sensitive. With XML, the tag <Letter>
is different from the tag <letter>
.
- All XML elements must have a closing tag.
Note that the declaration is not a part of the XML document itself. It is not an XML element, and it should not have a closing tag.