aspose file tools*
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 Spring in Action this week in the Spring 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: 12803
    
    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