Attributes
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, 2001</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: ...
Get Inside XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.