
Appendix A: Introduction to XML | 405 |
The prefix is common for letting applications reading the document know that it is indeed an XML document. The version is
The angle brackets, < and >, define the markup in XML. For the file prefix, content is placed between <? and ?> character sequences, but as the following sections show, most other markup is different.
XML Elements
The XML elements in Listing
<elementName>value</elementName>
In the previous example, elementName is the name of the element and value is the data associated with that element. Elements always have a begin tag and an end tag. You can identify the end tag because it always follows the begin tag eventually (there may be other element tags nested in between the pair) and contains a forward slash character before the element name.
The value in the previous example can sometimes be blank, meaning there is no value for that element. A value can also be one or more elements, such as customer, in Listing
Attributes
An attribute decorates an element with a single value, such as in the following example:
<elementName attributeName="attributeValue"> elementValue
</elementName>
Notice that the attribute, attributeName, is inside of the start tag of the element. It contains an equal sign and a quoted value. You can have multiple attributes on a single element and they’ll be separated by spaces. Remember that attributes can have only one value, but if you need to define more than one value, you must use elements.
Examples of attributes in Listing