on 11-27-2012 5:39 AM
Hi
What is the use of attribute in the data type...why cannot we just create it as an element ?
Thanks
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:
Attributes consist of a named pair attached to an element start-tag. An example of how an attribute is, "ID" at below:
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:
Elements are used to encapsulate pieces of data, and attributes are generally used to provide accompanying information about an element, rather than to encapsulate raw data itself.
Read more: http://wiki.answers.com/Q/What_is_difference_between_elements_and_attributes_in_XML#ixzz2DOnCTqE6
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:
But it would be invalid to have:
2. Elements can be defined to be in a certain order, while attributes can appear in any order.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.