O'Reilly logo

XML Companion, The, Third Edition by Neil Bradley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Element or attribute

In a few cases, there is no choice of whether to use an element or an attribute for a given piece of information. For example, if it is a reference to a binary entity, then it must be an attribute value, as the XML standard does not allow such references in element content.

More usually, information could be represented either by a child element or by an attribute. In some cases, either an element or an attribute would be equally well suited to the task, and even professional model designers would argue over some decisions. But in other cases, one or the other would be more suitable, and there are some guidelines that may assist in making this decision.

An element should be chosen if the information:

  • is a sub-division of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required