• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Simple question

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the rule for when to use an attribute or when to use the body of the tag.
For example in what case would you want to use this:
<user name="bob" />

And when would you use this:
<user>bob</user>

I'm just wondering how you decide which is more appropriate.

Thank you!
 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The questions realtes to when to create a attribute ?

1. When the data needs to be idetified uniquely, u shud go for Attribute. As if the atribute is of ID type it is unique...

2. U can also use ID/ IDREFS with attribute..

3. U can fix the value domain for the attribute values using the Enumeration..

There are many more... please add to this....
 
Ranch Hand
Posts: 578
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Jared Sprague:
What is the rule for when to use an attribute or when to use the body of the tag.
For example in what case would you want to use this:
<user name="bob" />

And when would you use this:
<user>bob</user>

I'm just wondering how you decide which is more appropriate.

Thank you!



Well that is a life long debate which i am sure would never end

There is no rule as such. Its a matter of personal preference
See these links

http://www-106.ibm.com/developerworks/xml/library/x-eleatt.html
http://www.ucc.ie/xml/#attriborelem

Enjoy


HTH
Hari
 
Maybe he went home and went to bed. And took this tiny ad with him:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic