Friday, May 18, 2012     You are here: Products  »  XML  »  XML Thunder™ - XML SOAP JSON for COBOL or C  »  XML Thunder Wiki   Search
XML Thunder Wiki

RSS

What is the Difference between Elements and Attributes?

Both elements and attributes have been designed to have a Name and a Value.

Elements can be parents of other elements and/or attributes and can be repeated within the same level of an XML document. They also usually have start and end tags. An element would look like:

Image

Attributes consist of a named pair attached to an element start-tag. An example of how an attribute is:

Image

Attribute values must be enclosed in single or double quotes. Attribute names must be unique within a single element occurrence.

The decision to use Elements versus Attributes is mostly an architectural one; however, there are some key differences between Elements and Attributes:

1. Elements can occur more than once (repeating) within the same level, while attributes can only appear once within the same level, example:

It is okay to have:

Image

But it would be invalid to have:

Image

2. Elements can be defined to be in a certain order, while attributes can appear in any order.

If you would like to get some extra details on this matter, please see visit one of the following web-pages:

http://www.itworld.com/nl/xml_prac/12132001/

http://xml.coverpages.org/elementsAndAttrs.html
Privacy Statement  |  Terms Of Use
Copyright © 1994-2012 by Canam Software Labs, Inc.
Login   Register