Understanding Elements and Attributes

The primary components described in a DTD are elements and attributes, which are responsible for establishing the logical structure of XML documents. You can think of an element as a logical unit of information, while an attribute is a characteristic of that information. In other words, an element represents an information object, while an attribute represents a property of that object. This is an important distinction because there is often confusion over when to model information using an element versus using an attribute.

When you're deciding whether to use an element or attribute to model information, a good approach to take is to consider the role of the information in the context of the overall document. ...

Get XML Unleashed 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.