Wednesday, June 10, 2009

XML Element or Attribute


elements are for data, attributes are for metadata

If data in question is a core content (problem domain) then it should be element.

If data is peripheral (intended to help the main communication) then it should be attributes.

If data has fixed format and cannot be extended should be attributes – ex Dates

If data has variable format and can be extended in future it should be element

If data is going to be read by human then put it in element

If data is going to be read by machines then put it as attribute

If data can be qualified by some attribute then it should be in element.