Adding Attributes

Within the sample document (Listing 2.2), there are several open tags that include extra information in the form of

						name="data"

These name/value pairs are called attributes. An attribute is generally a piece of information that is related to an element, but is not necessarily part of the content. Deciding what content should be encoded as an attribute and what should be left as element content is a topic that still generates a great deal of discussion among XML experts. Without digging too deeply into the various attribute philosophies, treating attributes as “keys” to the underlying element content is a fairly standard practice among experienced XML document authors.

You should keep a few restrictions in mind when using attributes ...

Get Strategic 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.