- XML Elements
- Generic Identifiers
- Some Rules for Naming Elements
- Storing the Data in XML
- Parsed Character Data
- Bypassing Parsing with CDATA
- Attributes
- When to Use Attributes
- Classifying Attributes: Attribute Types
- Attribute Rules
- Well-Formedness Rules
- Creating a Well-Formed XML Document
- The Basics of Validation
- How Do Applications Use XML?
- An Overview of XML Tools
- Roadmap
- Additional Resources
Attributes
Elements are the most fundamental component of an XML document; all XML documents have at least one element, the root element. However, there is also another fundamental mechanism for XML documents, which allows associating name/value pairs with elements: attributes.
Attributes should already be familiar to you from HTML:
<IMG SRC="logo.gif" BORDER="0">
The IMG tag makes use of many attributes, including the SRC attribute, which is used to associate the location of the image, and the BORDER attribute, which specifies the width of the image border.
Attributes Supplement Elements
Attributes are best utilized to store data that might not be important to the document structurally, but increase the informational value of an element. For example, in a document describing photographic equipment, we might have a camera element. For the camera element, it might make sense to have an attribute called format with values such as APS or 35mm. That's an attribute that relates to the element; it makes sense. However, you probably wouldn't want to have an attribute called phone, unless it's a very unusual camera.