Re: Attribute Usage

> What is the purpose of element attribute?  And is there a usage
> rule-of-thumb for element attribute (attribute vs. child element) ?
>

As noted, there is no hard-fast rule. Most programmers I've dealt with tend
to prefer elements over attributes, probably because at first, with DOM,
it's easier to deal with elements than attributes. Probably the best
argument I've heard for elements over attributes is that they can be
extended a lot easier. On the other hand, the best argument for attributes
has got to be size. If you deal in large XML documents (like I do,
converting EDI into XML), then the XML document can be drastically reduced
if you use Attributes for your "fields" (there's only one name per field,
instead of two for the open/close tag of elements).

All in all, I personally prefer using elements over attributes, though see
valid justifications for both, pure and mixed.

HTH,

Bryce K. Nielsen
SysOnyx, Inc. (www.sysonyx.com)
Makers of xmlLinguist, the affordable EDI to XML Translator
http://www.sysonyx.com/products/xmllinguist

Received on Friday, 18 March 2005 03:39:00 UTC