Please Share Feedback


Questions, comments, suggestions? Let us know what you think on our Forum.

To contact us privately, please use our contact form.

Author: Elyse, PMP, CPHIMS
June 27, 2004


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.

Subscribe and Share!

Did you enjoy this article? Your feedback is very important! I'd like to invite you to keep up to date with the latest posts from Anticlue. We offer several venues. If you have some questions, help can be found here.
 

3 Comments to “An Element or An Attribute”

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.

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)

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" /]


« Healthcare reporting and XML Security & Programming »

Please share your thoughts and suggestions