on 01-23-2008 12:18 PM
Hi Gurus,
Please provide me the difference between element and attribute.
It would be great,if I can get some example with exact usage.
Regards,
MohanRaj
Hi Mohan,
Elements contains information as an independent field, while attributes are those which contains data about that element means its meta data.
For eg: If ABC is a Node and it contain Field Name then Field Name is its element and at the same level If ABC have color, size, etc like fields then they are attributes which are common for all elements.
Rewards if found helpful.
BR, Kasturika Phukan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Element is everything from (including) the element's start tag to (including) the element's end tag.
An element can contain other elements, simple text or a mixture of both. Elements can also have attributes.
Attributes often provide information that is not a part of the data. In the example below, the file type is irrelevant to the data, but important to the software that wants to manipulate the element.
In case you use the JDBC Adapter, for example. The muster XML-SQL from help.sap.com use attribute action to describe what kind of action should be performed, but action does not belongs to Payload, for example the content you want to insert into one table, does NOT contain action.
<root>
<StatementName1>
<dbTableName action=UPDATE | UPDATE_INSERT>
<table>realDbTableName</table>
<access>
<col1>val1</col1>
<col2>val2new</col2>
</access>
<key1>
<col2>val2old</col2>
<col4>val4</col4>
</key1>
<key2>
<col2>val2old2</col2>
</key2>
</dbTableName>
</StatementName1>
regards,
Hai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer this thread
http://help.sap.com/saphelp_nw04/helpdata/en/0d/5ab43b274a960de10000000a114084/frameset.htm
Regards,
Sakthi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohan,
Elements and Attributes
You create complex data types using elements and attributes in the XSD editor:
Node Type
Use
Example Instance
Element
Create structured data types. Elements that have a type cannot contain subelements.
<myElem>
<f1> Value of f1 </f1>
<f2> Value of f2 </f2>
</myElem>
Attribute
Add attributes to elements. Attributes cannot usually have subnodes.
<myElem myAttr="AttributeValue">
Element Value
</myElem>
You can flag an attribute as optional or required in the Occurrence column. These values mean the same for elements with an occurrence of 0..1 or 1. The only difference between elements and attributes is that attributes cannot have subnodes and that the same attribute cannot be used more than once in an element.
Regards,
Phani
Reward points if Helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, attribute is only an attribute of element's entity. You can have just element w/o attribute, but can't have attribute w/o element.
See some pages about XML.
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohan!
This is a philosophycal question - attributes vs. elements. Technically it will work if you do in anyhow. The difference is only logical.
you can create a DT like
<person>
<name></name>
<age></name>
</person>
but also like
<person name="myname" age="myage"/>
so, depends just on your opinion, what you like more. The truth is, it is a bit easier to process attributes in XSLT and in some programming languages. But as I said, depends only on you.
Peter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.