xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clark C. Evans" <...@clarkevans.com>
Subject Re: Attribute and Element
Date Thu, 18 May 2000 22:27:47 GMT
> 	The confusion I am having now is, should I put the Price (or
> ValidBefore) as an attribute of the Ticket or put it as an element under
> the Ticket. What is the difference, and what is the benefits?

Attributes:
  * unordered
  * non-nestable  
  * usually implemented as an array or hash-table  
  * a bit briefer 
  * good for really short stuff (longer stuff gets ugly) 
  * all attributes are delivered together as one 
    unit in the SAX api.

Elements:
  * ordered
  * nestable
  * usually implemented as a linked-list 
  * a bit more verbose
  * good for longer stuff
  * elements are delivered seperately, sequentially
    in the sax api.

In general; I "religiously" stick to elements unless some
XML specification forces me to do otherwise.  The XPATH
is different for attribute vs element children; thus
changing can be painful.  Especially if one needs "more
structure" later on... ie, the ability to nest.

Hope this helps.

Clark


  


Mime
View raw message