Attributes

Elements are the most fundamental component of an XML document; all XML documents have at least one element, the root element. However, there is also another fundamental mechanism for XML documents, which allows associating name/value pairs with elements: attributes.

Attributes should already be familiar to you from HTML:

<IMG SRC="logo.gif" BORDER="0"> 

The IMG tag makes use of many attributes, including the SRC attribute, which is used to associate the location of the image, and the BORDER attribute, which specifies the width of the image border.

Attributes Supplement Elements

Attributes are best utilized to store data that might not be important to the document structurally, but increase the informational value of an element. For ...

Get Special Edition Using XML, Second Edition 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.