XML Attributes, XML Tutorial, Global Guideline

Bookmark Bookmark: XML Attributes, XML Tutorial
Forum | Blog


      Home                    

Basic XML Guide.       
 XML Introduction.       
 XML Tags Guide.       
 XML Attributes.
 XML Syntax Guide.    
 XML Compilation.      
 XML Execution.          
 XML with CSS.           
 XML with XSL.            
 XML Data Island.        
 XML Professional.       
 XML with JavaScript. 
 XML Namespaces.      
 XML CDATA.              
 XML Editors.               
 XML Summary.           

XML Tutorial >> XML Attributes.


     Back             Next     
In XML tags we can also define XML tag attributes.  Like in HTML suppose we use the HTML table tag then in element table we can also define the border, table width and others also. Same convention we can also follow in XML with tag attributes and these attributes are used to provide additional information about tags. Like...

Syntax for XML Attribues

<employee gender='m'>
  <firstName>Creston</firstName>
  <lastName>Narvon</lastName>
  <DOB>22/04/1976</DOB>
</employee>

Note on above XML Attribute example instead of a separate tag for Gender we use employee tag attribute "gender".  The major rule for attribute values is to be enclosed in quotes always, either in single quotes or double quotes, any one can be used. As shown in above we use single quote to assign value to gender attribute. We can also use it as <employee gender="m"> convention for using XML Attributes..

XML Attributes Preference.

The preference in XML is to use the XML tags instead of XML attributes because it would be quite difficult to handle XML attributes in other applications that's why the preference is to use XML elements or tags for the replacement of XML Attributes.  Like the below example.

Preferred XML Document Convention.

Preferred XML Elements:

<employee>
  <firstName>Creston</firstName>
  <lastName>Narvon</lastName>
  <DOB>22/04/1976</DOB>
  <gender>m</gender>
</employee>


Not Preferred XML Elements:

<employee gender='m'>
  <firstName>Creston</firstName>
  <lastName>Narvon</lastName>
  <DOB>22/04/1976</DOB>
</employee>

Why the Preference is to use XML Tags instead of XML Attributes?

Because the XML attributes make an XML document more complex and on the application ends it is quite complex and difficult to extract the value of an XML attribute as compare to the XML elements.  Because of this complexity in future the extensions will be focus on elements not on attributes.  Even when we saw the latest software's available in market such as Oracle products Visual Studio dot net they all use the XML elements only no complex kind of XML attributes are used in those elements.  The other way is an element can be accrue more then one time but the attribute we can define once not more then one for a single XML entity.  XML Attributes can't describe the structure of XML document but an element it self is a part of XML document structure so the conclusion is of this section of XML Tutorial is that we strongly appreciate and will also use XML Elements in our XML Tutorial to explain any thing instead of XML Attributes.


     Back             Next     
 

[ About ] [ Contact ] [ Home ]
[ Links ] [ Site Map ] [ Services ] [ Privacy ]

Copyright 2005 -  2018 www.globalguideline.com All rights reserved. (Best viewed in IE 6.0+ or Firefox 2.0+ at 1024 * 768 or higher) 164 visitors are online now