LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives


XML-L Archives

XML-L Archives


View:

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

Options:

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


Subject:

Re: Attributes and Elements

From:

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

Reply-To:

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

Date:

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

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

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
with
> 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
it
> could be done in either of the following ways.

>
<person><surname>Bloggs</surname><firstname>Joe</firstname><address>Somewher
e</address><./person>

> 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...?

Regards,

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

Permalink



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager