This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML:  Element or Attribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML:  Element or Attribute" Watch "XML:  Element or Attribute" New topic
Author

XML: Element or Attribute

Jeff Hinsman
Greenhorn

Joined: Sep 10, 2009
Posts: 3
I am new to XML. Just curious. Generically speaking, which is better, an attribute or element. I guess you can't have repeating attributes.


Thanks,

New Java Developer ;)
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
As I am sure you expected, the answer is "it depends" - there are some generalizations:

As you mentioned, repeating items belong in elements.

Elements are required for text that has to be in CDATA sections.

Attributes are ideal for "metadata" qualifying the element content.

Bill
Jeff Hinsman
Greenhorn

Joined: Sep 10, 2009
Posts: 3
Thanks! I think the key there is metadata. I am taking over some schema's someone else created an almost everything is an attribute. Seemed "ugly" to me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML: Element or Attribute
 
Similar Threads
Question on XML Schema restriction
New to XML Question
General XML related question...
connection timeout.
Significance of this tag