XML Syntax
An XML document is structured on the following building blocks:
- Elements
- Delimited by starting and ending tags
Example:
<title>The Lord of the Rings</title>
Elements can also be empty; a special shortcut makes them smaller:
Example:
<dvd></dvd>
is the same as
<dvd />
- Attributes
- Name=valua pairs in the starting tag, that can be used for metadata
Example:
<title lang="english">The Lord of the Rings</title>
- Entity references
- Are used to refer to special (reserved) symbols
Symbol | Entity reference |
< | < |
> | > |
& | & |
" | " |
' | ' |
- Comments
- Delimited by the <!-- and -> sequence
Example:
<!-- this is a comment ->
Example
<!-- List of shipped books -->
<booklist>
<book>
<isbn>0-387-02620-7</isbn>
<title>Beyond Fear</title>
<author>
<givenname>Bruce</givenname>
<familyname>Schneier</familyname>
</author>
<price>30.00</price>
</book>
<book>
<isbn>0-201-79940-5</isbn>
<title>Code Reading</title>
<author>
<givenname>Diomidis</givenname>
<familyname>Spinellis</familyname>
</author>
<price>50.00</price>
</book>
<book>
<isbn>0-07-246535-2</isbn>
<title>Database Management Systems</title>
<author>
<givenname>Raghu</givenname>
<familyname>Ramakrishnan</familyname>
</author>
<author>
<givenname>Johannes</givenname>
<familyname>Gehrke</familyname>
</author>
<price>40.00</price>
</book>
<book>
<isbn>0-19-502402-8</isbn>
<title>The Timeless Way of Building</title>
<author>
<givenname>Cristopher</givenname>
<familyname>Alexander</familyname>
</author>
<price>60.00</price>
</book>
<book>
<isbn>3-8218-0479-3</isbn>
<title lang="german">Lexikon der Populaeren Irrtuemer</title>
<author>
<givenname>Walter</givenname>
<familyname>Kraemer</familyname>
</author>
<author>
<givenname>Goetz</givenname>
<familyname>Trenkler</familyname>
</author>
<price>40.00</price>
</book>
</booklist>