- by MB
I know the elements versus attributes debate has come up many times here and elsewhere (e.g. here, here, here, here, and here) but I haven't seen much discussion of elements versus attributes for simple property values.
So which of the following approaches do you think is better for storing a simple value?
A: Value in Element Content:
<TotalCount>553</TotalCount>
<CelsiusTemperature>23.5</CelsiusTemperature>
<SingleDayPeriod>2010-05-29</SingleDayPeriod>
<ZipCodeLocation>12203</ZipCodeLocation>
or B: Value in Attribute:
<TotalCount value="553"/>
<CelsiusTemperature value="23.5"/>
<SingleDayPeriod day="2010-05-29"/>
<ZipCodeLocation code="12203"/>
I suspect that putting the value in the element content (A) might look a little more familiar to most folks (though I'm not sure about that).
Putting the value in an attribute (B) might use less characters, but that depends on the length of the element and attribute names.
Putting the value in an attribute (B) might be more extensible, because you could potentially include all sorts of extra information as nested elements. Whereas, by putting the value inside the element content (A), you're restricting extensibility to adding more attributes. But then extensibility often isn't a concern for really simple properties - sometimes you know that you'll never need to add additional data.
Bottom line might be that it simply doesn't matter, but it would still be great to hear some thoughts and see some votes for the two options.