Attributes vs. Elements:
represent atomic data represent structured data usually represent properties of object represent parts of object can represent relationships (ID/IDREF types) can represent relationships by including one element into another often represent data that is less important, or data about data may appear only once on an element my appear many times inside another element appears at no guaranteed order, as a set may be required to appear in specified order cannot be "extended" by adding sub-attributes can be extended by adding sub-elements must have unique name within an element There can be several elements with the same name inside another element values are often short and simple values can be long make document concise make document verbose cannot contain <![CDATA[ blocks. can contain <![CDATA[ blocks. cannot have external parsed entities as a value can have external parsed entities as a value can have external unparsed entities or notations as a value (if declared of ENTITY, ENTITIES, NOTATION type) no?
All below was written with DTDs in mind
can be validated to have enumerated values (from a list) cannot can be validated to have unique values cannot can have default values cannot
1. Beginning XML. David Hunter, Curt Cagle, Dave Gibbons, Nikola Ozu, Jon Pinnock, Paul Spencer. Wrox Press Ltd.
2.When Should I Use Elements, and When Should I Use Attributes?
3. The Attribute/Text Conundrum. "Document-Centric" vs. "Data-Centric"
"Elements and attributes are both containers for information. Many times the choice between an element and an attribute seems very arbitrary, almost matter of style. While the choice may indeed be arbitrary in some cases, the 'typical' roles of elements and attributes and the different types of content models and constraints these two containers support may tip the scales in one direction or the other."
"Use attributes when you can, and elements when you have to
· Makes the document easier to process using SAX or the DOM
· Makes documents smaller and therefore documents can be processed more efficiently
This rule is fairly self-explanatory. Not everyone is convinced that this is the best way. Arguments against attributes usually assert that elements are easier for humans to read. However, attributes lead to significant performance improvements when processing is involved. The advantages of attributes can not be ignored if scalability is a priority."