- 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
Attribute Rules
Attribute type names are subject to the same naming rules and conventions as elements. The names are case sensitive, so NAME and name are not the same:
Attribute names cannot contain spaces. An attribute could be called FirstName but not First Name.
Attribute names must begin with a letter (or the underscore). So, Four11 would be an acceptable attribute, whereas 411 would not.
Attribute values must be enclosed in quotation marks.
An element may have only one attribute of a given name.
Attribute content may not contain <, >, or &.
Although attribute content must be contained in quotation marks, you can nest quotation marks within attribute content. To nest quotations, you simply use double quotation marks and single quotation marks, in either order:
<NAME First="John 'Stinky'" Last="Doe"/>
or
<NAME First='John "Stinky"' Last="Doe"/>
As long as the quotation marks are properly nested, the order in which you use single versus double quotation marks does not matter.