XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old May 16th, 2002, 01:27 AM
raybiez's Avatar
raybiez raybiez is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: Midrand, South Africa
Posts: 154 raybiez User rank is Lance Corporal (50 - 100 Reputation Level)raybiez User rank is Lance Corporal (50 - 100 Reputation Level)raybiez User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 2 Days 15 h 1 m 56 sec
Reputation Power: 8
Send a message via MSN to raybiez
Question Attributes vs Elements

After reading the "Idiot's Guide to XML", I was still confused about certain aspects of implementing XML.

Which is better to use?

<person name="John" surname="Doe"></person>

or

<person>
<name>John</name>
<surname>Doe</surname>
</person>
__________________
Neil Craig
Software Developer
SourceCode Techonolgy Holdings Inc
South Africa

Reply With Quote
  #2  
Old May 17th, 2002, 01:43 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
I read the same book. Pretty bland
It's completely up to you, though. It may depend on how you want to use the data, which way makes more sense, or if you just want to use fewer characters. You could also user /> instead of the closing tag...
I'd say how you're planning to use the data should be your guide.

Reply With Quote
  #3  
Old May 17th, 2002, 07:46 AM
Manuzhai Manuzhai is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 3 Manuzhai User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I think you should use elements for most things (especially properties of the parent element, like "name" for a "person"). IT seems to me that attributes are only useful if you want to make a distinction between instances of the same element, for example <phoneno type="home"> and <phoneno type="work">.

Reply With Quote
  #4  
Old May 17th, 2002, 10:24 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
Sure, but if you're wanting to model a real-life object, such as a person, you (a person) have an attributes, one of which is your name. Your name isn't some sub-part of who you are, not the way a driver's license number or address would be. It may be a unique way to identify yourself, but unless you're up to no good you've only got one =).
That's another criteria for attribute vs. element. You can have more than one element of the same type, but only one attribute. So middlename would probably be an element, since some people out there have several.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Attributes vs Elements


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway