Data can be stored in child elements or in attributes.
Take a look at this tutorials.
<firstname>Anna</firstname>
<lastname>smith</lastname>
</person>
--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
<person>
<sex>Female</sex>
<lastname>smith</lastname>
</person>
In the first tutorial sex is an attribute. In the last sex, is a child element.Both examples provide the same information.
There are no rules about when to use attributes, and when to use child elements. My experience is that attributes are handy in HTML, but in XML you should try to avoid them. Use child elements if the information feels like data.
May 6, 2009
0 Use of Elements vs Attributes
Posted by raj on 12:57 AM
0 comments:
Post a Comment