LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives

XML-L Archives

XML-L Archives


Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font


Join or Leave XML-L
Reply | Post New Message
Search Archives


Re: Attributes and Elements


"Senior, Chris" <[log in to unmask]>


General discussion of Extensible Markup Language <[log in to unmask]>


Wed, 9 Sep 1998 11:39:29 +0100





text/plain (54 lines)

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
they be
> used?

> For example, in my eyes, if I wanted to store people name's and addresses
> could be done in either of the following ways.


> or

> <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
an object.)

Hope that helps a bit...?


Chris Senior

Diagnostic Software Research,
GenRad Inc.

Orion Business Park, Birdhall Lane,
Stockport, Cheshire, SK3 0XG, United Kingdom.

Reception: +44 [0]161 491 9191
Direct: +44 [0]161 491 9125
Fax line: +44 [0]161 491 9292

Email: [log in to unmask] <mailto:[log in to unmask]>

Back to: Top of Message | Previous Page | Main XML-L Page



CataList Email List Search Powered by the LISTSERV Email List Manager