|
-
Apr 4th, 2003, 11:28 AM
#1
Thread Starter
Addicted Member
XML Document Design (Attribute vs Element)
Thanks for the help on the other post. Now I have a design question....
I have noticed that some XML authors use attributes and others use elements. Is there any guidelines you guys use to make your XML documents?
I have been using elements for long text values and attributes for everything else (like example 3). But I noticed that a few people use elements and/or attributes for all items, etc.
PHP Code:
example 1.....
<user>
<firstname>John</firstname>
<lastname>Doe</lastname>
<category>4</category>
<gender>1</gender>
</user>
example 2....
<user firstname="John" lastname="Doe" category="4" gender="1" />
example 3...
<user category="4" gender="1">
<name>John Doe</name>
</user>
P.S. I think this is on VB.NET topic discussion, but it may fall under database topics. I would like to pick the brains of some of the VB users here, since they have helped me with other stuff in the past.
-
Apr 4th, 2003, 11:47 AM
#2
I don't know if there is a right or wrong answer for this one as much as just opinion. I usually use a lot of attributes or something like your number 3 example. The way the tables will come out will be different depending on you do it. For instance when opening the xml file into a dataset or the xpath query if you use the XMLDocument.
-
Apr 4th, 2003, 12:56 PM
#3
My honest opinion: Do what makes sense. There really isn't a right or wrong way. I've seen people stuff everything, no matter how long it is into attributes, and other things, that IMHO would have been better off as attribute, stuffed as the element....
-
Apr 4th, 2003, 07:31 PM
#4
Thread Starter
Addicted Member
Thanks for your opinions. I just like getting other people's ideas/opinions so when I show another programmer my code/XML he/she doesn't say "what the heck were you thinking"...
-
Apr 4th, 2003, 11:23 PM
#5
"what the heck were you thinking"
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
|