XML Elements
Home ] Up ] The Document Prolog ] [ XML Elements ] The Root Element ] XML Attributes ] Attribute vs. Element? ] Whitespace and Comments ] XML Character Entities ] CDATA Sections ] Processing Instructions ] Well-Formed Documents ]

 

 

XML documents are composed of elements.

An element consists of:

  • An opening tag, which:
    • has a name,
    • is contained within angle brackets (< >)
  • Element data (content)
  • A closing tag, which:
    • begins with an angle bracket, followed by a slash
    • uses the same name as the opening tag
    • ends with a closing angle bracket

Element (or tag) names in XML are case-sensitive.

For example:

<author>James Joyce</author>
<para>
This is a paragraph, which may be
continued over several
lines.
</para>

The closing tag is required.  However, if the element is such that it will never enclose content, then the element may be specified to be self-closing. For example:

<over-21/>
<br />
<hr/>
 
The page was last updated February 19, 2008