Posted by: Rajesh Kanaparti | April 27, 2008

Attribute VS Elements, its tricky

I work with XML a lot and often I come up with the question where I should go with Attributes or Elements.Most often i judge my decision based on the following opinions that I came across Google searches.

Attributes Elements
Used for holding meta-data (data about data, ex. ID numbers,information irrelevant to the users) Used for holding data
(information user wants to see)
Can only be defined by a data type Can be defined by a
data type,attributes, and structures (this makes them more extensible)
Not expandable for future changes (can only change its
data type)
Can add more attributes, change the data type or change its
structure
Cannot have multiple occurrences Allows for multiple
occurrences
Independent of ordering Dependent on positional
ordering

Please feel free to add on your opinions.


Leave a comment

Categories