Click to See Complete Forum and Search --> : xml and attributes??


jend
07-22-2003, 06:19 AM
I am new to XML and have a question on how to construct my document.

I have an element called UM which describes a unit of measure, for example EA.

<UM>EA</UM>

I also need to be able to provide the description of EA which is Each. Should I add a new element called UMDescription and put the description there, or can I use an attribute to describe EA? Or is there an even better way to do this?

I was thinking either:
<UM>EA</UM>
<UMDescription>Each</UMDescription>

or
<UM Description='Each'>EA</UM>

Any suggestions on the best way to do this would be extremely appreciated. I've got this kind of thing occuring throughout my document.

Thanks!

Khalid Ali
07-22-2003, 09:04 AM
I don't think there will be any serious gains or what not...it all comes to personal choice,it will work both ways...

Charles
07-22-2003, 12:40 PM
I'll second that, it's a matter of choice but it's a good idea to use attributes to describe an element. Id est:

<book>
&nbsp;&nbsp;&nbsp;&nbsp;<title>On the Concept of Irony</title>
&nbsp;&nbsp;&nbsp;&nbsp;<author>S. A. Kierkegaard</author>
&nbsp;&nbsp;&nbsp;&nbsp;<date scheme="W3CDTF">1841-05-09</date>
</book>