What is an ELEMENT ?
An Element is the building block of an XML document. Each element has a name and a context.
<Sport>Tennis</Sport>
The name of the
element is enclosed by the less than and greater than characters, and these are
called tags. There are 3 types of tags.
- Start-Tag
In the example <Sport> is the start tag. It defines type of the element and possible attribute specifications
<Player firstname="Andre" lastname="Agassi">
- End-Tag
In the example </Sport> is the end tag. It identifies the type of element that tag is ending. Unlike start tag end tag cannot contain attribute specifications.
- Empty Element Tag
Like start tag this has attribute specifications but it does not need an end tag. Denotes that element is empty (does not have any other elements). Note the symbol for ending tag '/' before '>'
<Player firstname="Andre" lastname="Agassi" / >
Rules for Naming Elements
- XML names should start with a letter or the underscore character
- Rest of the name can contain letters, digits, dots, underscores or hyphens
- No spaces in names are allowed
- Names cannot start with 'xml' which is a reserved word