Attributes

Attributes are name-value pairs that can be associated with an element. The attributes provide additional information about the element, and can be specified only in the start tag of an element. In our example, the id, type, capacity, and price attributes provide additional information about the engine element.

An important point to remember is that if you declare a set of attributes with an element in a DTD and then declare another set of attributes when the element appears again, the attribute set is merged. If the same attribute is defined twice, the second declaration is ignored and only the first one is considered. However, an XML document is considered invalid if it has an element that contains two attributes with the same name. ...

Get Java™ APIs for XML Kick Start 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.