ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing ExpertRating - Online Certification and Employment Testing

ExpertRating Home
ExpertRating Benefits
Recommend ExpertRating
Suggest More Tests
Privacy Policy
FAQ
Login
 
XML Tutorial - Index
XML Tutorial - Introduction to XML
XML Tutorial - How XML interact with data?
XML Tutorial - How to write first XML document
XML Tutorial - What are XML Elements and Attributes?
XML Tutorial - What is XML Schema and DTD?
XML Tutorial - Which Browser support XML?
XML Tutorial - XML and Styles
XML Tutorial - Embedding XML in HTML
XML Tutorial - Working with XML Parser
XML Tutorial - Working with CDATA
     

 
Online Personal Trainer Certification
Personal Trainer Certification (Spanish)
Six Sigma Certification
Find a Personal Trainer
Project Management Certification
Six Sigma Certification
Six Sigma Black Belt Certification
Master Black Belt Certification
Six Sigma Green Belt Certification
Life Coach Certification
Lean Management Certification
Lean Six Sigma Certification
First Aid Certification
CPR Certification
Yoga Certification
Aerobics Certification
Pilates Certification
Business Analyst Certification
SEO Certification
Online Business Writing Course & Certification
Makeup Artist Certification
Baby Sitting Course & Certification
Time Management Certification
Health Club Management Certification
Medical Coding Certification
Medical Billing Certification
Business Analysis Course
Master Trainer Certification
Total Quality Management Certification
Kaizen Certification
Creative Writing Certification
Event Management Certification
Test Search by Job Title
Administrative Assistant Certification
Virtual Assistant Certification
  All Online Courses
   

   
   
   
   
   
   

   
  Home > Courses, Tutorials & eBooks > XML Tutorial > What are XML Elements and Attributes?
 

XML Tutorial - What are XML Elements and Attributes?

 
Page 1 of 2
 
Overview
 
In this chapter you will learn :
  • What are XML elements and attributes?
  • How to name an element tag and an attribute?
  • Which one is more efficient to use, amongst attribute and element?
  • What are the advantages and disadvantages of using both?

 

XML Elements

Elements are considered to be the basic building blocks of any mark up language. Each element has its own specific properties and functions. XML's element mark up is composed of 3 parts :

    1. A start tag.

    2. The contents.

    3. The end tag.

  • Each element begins and ends with its element name ( usually referred to as a tag) .

  • Each element begins with what is commonly called a start tag or an opening tag .

  • Generally, each element ends with an end tag also called as a closing tag .

  • Each tag name is delimited by angle brackets ( < indicates the beginning of the tag name; > indicates its end ) .

  • In the end tag, the element name is always preceded by a slash ( / ) .

  • Every start-tag must have a matching end-tag.

  • Tags cannot overlap. Proper nesting is required.

  • The start tag and end tag should be treated like wrappers, and whenever you think of an element, you should have a mental picture of a piece of text with both tags in place.

    Syntax
              < element name >  .....  content  .......  < /element name >
    Example                               
                     <P>  This is content of paragraph. </P>
    Here, <P> indicates the start tag and </P> indicates the end tag and the content lies in between these two tags.

    Note
    The exception to this rule is the declared empty element( already discussed in previous chapter), which does not have an end tag, but does have a special start tag.

XML Attributes

Elements may or may not include attributes (also called attribute specifications). They are type of data that you can specify for your elements, and they appear in the form of name-value pairs.

  • Attributes are used to attach information to the information contained in an element.

  • The general form for using an attribute is :

    Syntax
                                      < element.name  property = " value " >

                  Symbol                                               Description
    < Start tag open delimiter
    element.name Element name
    property Attribute name
    = Value indicator
    " Literal string delimiter
    ' Alternative literal string delimiter
    value Value of the attribute
    > Start tag close delimiter

  • An attribute value must be enclosed in quotation marks. You can use either single quote (< fruit size = 'big'>) or double quotes (<fruit smell = "pungent">), But you cannot mix the two in the same specifications.

  • When you specify attributes for the same element more than once, the specifications are simply merged.
     
    Example
                                 < !-- Element with attributes -->
    < ?xml version = "1.0" >
    <My.page>
    <student rollno = "first" > Student has roll number 1.</student>
    <student rollno = 'second' remarks = 'obedient' > Student is obedient. </student>
    </My.page>
     

 

 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2015. All Rights Reserved.