June 27, 2004

An Element or An Attribute

For newbies with XML there is one basic thing to know. How to label the data in the most effective manner for future growth.

Attributes cannot be further drilled down into subelements. However Elements can be broken down into more detail.

Elements are the easier way to go if you are looking at standardizing the schema. Attribute need slightly more complex coding to be able to handle their existence.

Posted by Elyse at June 27, 2004 8:38 PM | TrackBack
Comments

Attributes are quicker to parse in Flash Player 6+, and are easier(opinion) to access via the attributes property since it's an array. However, the actual XML, when done and succint, lacks a lot of depth, and most XML schema's I've used professionally (not written by me, like Live Journal, Atom, RSS, etc.) all have extensive elements for sub-info, so I see your point.

I'm subjective, because much of a Flash developer's life is parsing XML.

Posted by: JesterXL at June 27, 2004 10:02 PM

as jester, the only times i have had a problem with the way an xml doc is structured is when i'm bound by a particular schema... where i'm free to decide, i'm biased towards attribs (i try to cut down on markup... just too verbose) however, your post title does it for me... is it an _element_ or an _attrib_? on code complexity b/n attribs and elements, i don't necessarily agree... it boils down to app context and the level of granularity you are seeking... an xml node with a lot of attribs looks more like a value obj (coarse-grained), one with more elements, a finer-grained obj..

... an example would be, say, a dob for person Foo

we could approach this in a number of ways, but just to illustrate els and attribs:

//_A_ with dob broken down


2
28
2004


// _B_ dob as attrib


depending on the application requirements, _A_ might be just right (which would make _B_ look like it requires complex coding to come to the level of _A_) or _A_ might be just overkill (beware of we-might-need-it-later features)

Posted by: eokyere at June 27, 2004 11:00 PM

oops.. looks like my xml got cropped...

shd look like:

_A_ //

[person name="Foo"]
[dob-month]2[/dob-month]
[dob-date]28[/dob-date]
[dob-year]2004[/dob-year]
[/person]


_B_ //
[person name="Foo" dob="02-28-2004" /]

Posted by: eokyere at June 27, 2004 11:03 PM
Post a comment









Remember personal info?