You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by cl...@clarkevans.com on 2000/05/19 00:49:48 UTC

Re: Attribute and Element (fwd)

> 	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