News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

Avoid using attributes?

Started by ben2ong2, October 05, 2006, 05:06:19 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben2ong2

Should you avoid using attributes?
Some of the problems with using 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
·   attribute values are not easy to test against a Document Type Definition (DTD) - which is used to define the legal elements of an XML document
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.
Don't end up like this (this is not how XML should be used):
<note day="12" month="11" year="2002"to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!"></note>
You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login