Elements or Attributes?

Should you avoid using attributes?

Some of the problems with attributes are:

  • attributes cannot contain multiple values (child elements can)
  • attributes are not easily expandable (for future changes)
  • attributes cannot describe structures (child elements can)
  • attributes are more difficult to manipulate by program code

If you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. Use attributes only to provide information that is not relevant to the data.

Visit this link for more info on the subject.

<item id="69" type="book">
      <author>
          <name>John Smith</name>
      <author>
    <ISBN>123456790</ISBN>
</item>

 

Post A Comment

Anti-Spam Quiz: