On Wednesday, September 09, 1998 10:25 AM
Steve Hill Wrote :
> I do not know if anyone can help me, but I have recently become involved
> XML and have a query to which I can find no answer!
> What is the different between attributes and elements and when should
> For example, in my eyes, if I wanted to store people name's and addresses
> could be done in either of the following ways.
> <person surname="Bloggs" firstname="Joe" address="Somewhere"/>
> Any help would be gratefully received.
I have two rules for when and where to use attributes or elements...
1) If there are multiple occurrences of an element and you need to
distinguish individual occurrences then attributes are a logical way of
distinguishing between occurrences. (E.G. If there are multiple "person"
elements then "surname", "firstname" etc. would logically be attributes.)
2) Consider a user entering data into the XML. Does "surname" and
"firstname" describe a "person" or is it just data that is part of a
"person". (To put this in an object oriented way - "attribute" is a
property that describes an object. "element" is another object contained by
Hope that helps a bit...?
Diagnostic Software Research,
Orion Business Park, Birdhall Lane,
Stockport, Cheshire, SK3 0XG, United Kingdom.
Reception: +44 161 491 9191
Direct: +44 161 491 9125
Fax line: +44 161 491 9292
Email: [log in to unmask] <mailto:[log in to unmask]>