Results 1 to 5 of 5

Thread: XML Document Design (Attribute vs Element)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164

    Question 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.
    -Shurijo

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    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....
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 1999
    Posts
    164
    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"...
    -Shurijo

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    "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
  •  



Click Here to Expand Forum to Full Width