January 2003
Beginner to intermediate
1200 pages
23h 42m
English
We've already discussed attributes in some detail; they're those name-value pairs that you can use in start tags and empty tags to provide additional information for an element. Here's an example. In this case, I'm adding an attribute named TYPE to the <CUSTOMER> tag to indicate what type of customer a person is:
<CUSTOMER TYPE = "excellent">
<NAME>
<LAST_NAME>Smith</LAST_NAME>
<FIRST_NAME>Sam</FIRST_NAME>
</NAME>
<DATE>October 15, 2003</DATE>
.
.
.
You can use attributes like this one and assign them values in XML documents, but unless you also declare them, your document won't be valid. You can declare a list of attributes for an element with the <!ATTLIST> element in the DTD. Here's the general form of an <!ATTLIST> element: