Topic: xml: how do you write it? (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=10748" title="Pages that link to Topic: xml: how do you write it? (Page 1 of 1)" rel="nofollow" >Topic: xml: how do you write it? <span class="small">(Page 1 of 1)</span>\

 
GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 06-05-2002 19:18

would you rather write:

<firstname>Mary</firstname>

or

<firstname value="Mary" />

synax
Maniac (V) Inmate

From: Cell 666
Insane since: Mar 2002

posted posted 06-05-2002 20:21

Either way works, I'd use child elements though, like:

code:
<person sex="female">
[b]<firstname>Mary</firstname>[/b]
<lasname>Johnson</lastname>
</person>



Here's what I grabbed from W3Schools:

quote:
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





[This message has been edited by synax (edited 06-05-2002).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-05-2002 20:22

No hard rule on this but for this kind of thing 99% of the time it would be the first.

The second example is for the use of field attributes. Not generally for data fields.



.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 06-05-2002 22:49

interesting.
i always used the second version with attributes til now. hmmm.

they arent limited by any way, are they?

DmS
Paranoid (IV) Inmate

From: Sthlm, Sweden
Insane since: Oct 2000

posted posted 06-07-2002 09:55

You can look at it this way:
If the value will be used by the software only (for parsing, conditions, identifier, cathegorizing...) it most probably is an attribute and belongs inside the container tag, if it will be used/presented to the end user, it's not.

Both ways work I suppose, but since XML is a language supposed to be easily read by both machines and humans, separation and clarity of the code is important.

As for limitations... Well, XML swallows almost anything as long as it is well formed. What attributes you are allowed to use you can define yourself in a DTD, that's where all the validation rules on what you can use for each tag comes from.
/Dan

{cell 260}
-{ a vibration is a movement that doesn't know which way to go }-

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 06-23-2002 17:12

Coming to this a little late but if you are producing the XML to feed data to Flash (as I suspect you are) then I believe using attributes greatly speeds up the parsing of the data as it takes Flash longer to work with nodes.

___________________
Emps

FAQs: Emperor



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu