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
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 > How to write first XML document?
 

XML Tutorial - How to write first XML docuement?

 
Page 1 of 1
 
Overview
 
In this chapter you will learn :
  • How to write an XML document?
  • What are the important parts of an XML program?
  • What is root element?
  • What are empty elements?

 

A sample XML document for a web page is shown below. It contains all the important parts that are usually contained in XML documents.

Example
<?xml version ="1.0"?>
<My.page>
<head>
<title> My home page </title>
<header source = "imagehead.gif "/>
</head>
<body>
<main.title> Welcome to my home page </main.title>
<rule/>
<text>
<para>
                 SORRY! This page is still under construction. Visit this site soon.
</para>
</text>
</body>
<footer source= imagefoot.gif "/>
</My.page>

XML Declaration

                  [i.e., <? xml version = "1.0" ?>]

  • The XML declaration identifies what follows it as XML code.

  • It states which version of the XML standard the code compiles with, and it specifies whether the document can be treated  as a stand-alone document or whether DTD ( Document Type Definition, [defined later in the tutorial] ) must also be retrieved in order to make full sense of the contents.

  • The XML declaration is a processing instruction (identified by the ? at its start and end).

    Note            
            The XML declaration is not strictly compulsory.

The Root Element

                [i.e., from < My.page> to </ My.page> ]

  • Each XML document must have only one root element, and all the other elements must be completely enclosed in that element.

  • In XML, an element normally consists of 3 things :

    1. a start tag.

    2. content (either text or other elements ).

    3. an end tag.

  • The name you use in the element start tag must exactly match the name you use in the end tag.

  • XML is case sensitive, recognizing the difference between uppercase letters and lowercase letters.

An Empty Elements

             [i.e., < rule/ > ]

  • Empty elements are a special case in XML.

  • XML requires you to be much more explicit when dealing with empty elements.

  • To do so, there is a special empty tag close delimiter, /> , as in the following :
                                                              <empty-element />

  • You can also use an end tag instead of the special empty tag close delimiter. The element declaration :
                        < graphic source= " image.gif "/>    is therefore interchangeable with
                         < graphic source= " image.gif ">.............</ graphic>

Attributes

                  [i.e., <header source="imagehead.gif"/> , <footer source = 'imagefoot.gif"/>]

  • Element tags can include one or more optional or mandatory attributes.

  • Attributes can only be specified in the element start tag.

  • The syntax for specifying an attribute is :

    Syntax
                   <attribute.type.name  attribute.name = "attribute.value" >
     
    Example
                     < fruit taste = "sharp" >

  • XML deals with multiple declaration of attributes in a unique manner. If an element appears once with one set of attributes and then appears again with a different set of attributes, the two sets of attributes are merged.

  • The first declaration of an attribute for a particular element is the only one that counts, and any other declarations are ignored.
 
Summary
 

In this chapter you have learnt:

  • About XML’s interaction with the data.
  • How XML is used to share information and exchange information?
  • How XML stores the data inside HTML ?

 

 
Review Questions
 

Fill in the Blanks

  1. The first line of an XML program is known as XML ---------.
  2. The root element is also known as --------- element.
  3. An element normally consists of three things, i.e., ------- tag, ------- and end tag.
  4. An element with no content in it is called -------- element.
  5. ------- are specified in the element start tag.

Solutions

  1. declaration
  2. parent
  3. start tag, content
  4. empty
  5. Attributes

True or False

  1. XML declaration is compulsory.
  2. There can be more than one root elements.
  3. XML is case sensitive.
  4. An empty element can have contents in it.
  5. Attributes are compulsory to specify in the element.
Solutions
  1. False
  2. False
  3. True
  4. False
  5. False

 

 
 
What's Next

The next chapter will acquaint you with the basic concepts of XML elements and attributes. The chapter will further elucidate how to name elements and attributes and various advantages and disadvantages of using elements and attributes.

                 Hop over to the next chapter to get an XML elements and attributes close-up.
 
   
 
 
     
Home  |  About Us  |  Privacy Policy  |  Site Map  |  FAQs  |  Contact Us
 
© ExpertRating 2006. All Rights Reserved.