Clouds
Home

XML Introduction

XML History

XML vs HTML

XML Syntax

XML Elements

XML Attributes

XML Validation

XML Elements


XML is a markup language that is used to store data in a self-explanatory manner. Making the data "self-explanatory" comes about by containing information in elements. If a piece of text is a title then it will be contained within a "title" element.

XML Elements are extensible. They have relationships. They have simple naming rules.

XML Elements are Extensible

XML documents can be extended to carry more information.

Look at the following XML example:

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Aish</To>
<From>Kundan</From>
<Body>Be ready for a cruise...i will catch u tonight</Body>
</E-mail>

Let's suppose that we create an application to fetch data from the above XML document and produce this output:

E-mail
To: Aish
From: Kundan

Be ready for a cruise...i will catch u tonight

Now, the author wants to add a new feature (let it be a subject line). He can easily achieve it by adding one more tag ie..<Subject>in the xml document. So the new modified xml document will look like this :

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Aish</To>
<From>Kundan</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u tonight</Body>
</E-mail>

Now the new generated output will look like this

E-mail
To: Aish
From: Kundan
Subject : Surprise....

Be ready for a cruise...i will catch u tonight

XML Elements have Relationships
Elements in a xml document are related as parents and children

Imagine that this xml document is a description of a e-mail:

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Aish</To>
<From>Kundan</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u tonight</Body>
</E-mail>

Here, E-mail is the root element while To, From, Subject and Body are the child elements of the E-mail. Here, E-mail is the parent element of To, From, Subject and Body. To, From, Subject and Body are siblings (or sister elements) because they have the same parentage. Hence , all the XML Elements have Relationships.



XML Element Naming : Know-hows
XML elements must follow these naming conventions:

  • Names must not start with a number or punctuation character but it can contain letters, numbers, and other characters without spaces.
  • Names must not start with the letters xml (or XML, or Xml, etc)
  • Elements are used to classify data in an XML document so that the data becomes "self-explanatory".
  • Opening and closing tags represent the start and end of an element.
  • Attributes are used to include additional information on top of the data that falls between the opening and closing tag.


    Home Clouds