in the above note element I've date as an attribute. But date can also be defined as a child element like <to>and <from> of note
What difference does it make having date declared as a child element or as an attribute of note element.
Then date would be an attribute for note and would be child for notes It can be possible if you define your DTD/Schema accordingly...
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
1
posted
0
What difference does it make having date declared as a child element or as an attribute of note element.
To some extent this is a author style thing with no hard and fast rule. I have seen plenty of XML extremes with no attributes or all attributes. As you gain more experience with the various XML toolkits I'm sure you will develop your own style.
Mainly you should be aware of the limitations on the character content in attributes before you try to use nothing but attributes.
Please find the below limitations of using the attributes rather elements
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
-Dhanasekar.T
Manish Shah
Greenhorn
Joined: Jun 09, 2002
Posts: 22
posted
0
Adding as a node is more preferable as it is easily readable. You can consider putting as an attribute if that attribute is short & constant. What if in the future there is a change expected in date to specify date format information ..? In this case you cannot go on adding attributes. It is rather better to have date as node so that it can be open for having child attributes.