|
-
Jun 6th, 2002, 04:33 AM
#1
Thread Starter
Fanatic Member
XML Document, HELP!
Hi,
I am a little confused about when you should use what. Here's an example:
Should I use this xml:
Code:
<person>
<name>shunt</name>
</person>
or should I use this xml:
Code:
<person name="shunt"/>
Can anyone tell me which one would be correct and why.
-
Jun 6th, 2002, 11:04 AM
#2
Black Cat
It depends on your requirements - if the person could have more than one name, you would need to use #1, so it really depends on your data model.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Jun 7th, 2002, 04:56 PM
#3
Attibutes are easier to use (shoter to write), and usually more clear.
But when you are planning to 'divide' the value or add extra options somewhere in the future it's better to use a child element right away.
Maybe sometime you want to be able to wite this:
Code:
<person>
<name>
John Johnes
</name>
<name>
<first-name>Bill</first-name>
<last-name>Gates</last-name>
</name>
</person>
You should also consider how you are going to edit these XML files. If you are using a text editor attributes have the benefit of being more readable. If you use some kind of XML editor, there is hardly any reason not to use child elements.
-
Jun 10th, 2002, 10:15 AM
#4
Lively Member
Also by going with attributes makes the file smaller.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|