Home > Articles > XML/XSL Articles > What is XML?

What is XML?

by Narain Siddharth   on Dec 19, 2010   Category: XML/XSL  | Level: Beginner  |  Views: 3050    |  Points: 100   
Like this article? Bookmark and Share:
In this article, im going to explain about basics of XML, uses, syntax, declarations, naming conventions and xml attributes for beginners.

What is xml?

  • XML stands for Extensible Markup Language.
  • XML is designed to describe the data and to focus on what data is.
  • XML is a cross-platform, software and hardware independent for transmitting information.
  • Like HTML, XML tags are not predefined we must define the tag.
  • To define the tag XML uses Document Type Definition (DTD) or XML Schema.

XML Uses:

  • XML is not a replacement for HTML,In future, XML will be everywhere in web development.
  • XML is mainly used to store and exchange the data.
  • XML is a platform independent we can transfer a data from different Operating System.
  • XML can support data from HTML also.
  • Main purpose of XML is to share and transfer data.
  • XML was designed to store, transfer and exchange data and not to display data like HTML.

XML Syntax:

  • XML elements are Case sensitive.
  • All XML elements should have closing tags.
  • XML Elements are extensible and they have relationship.
  • Elements are related as parent and children.
  • Elements have content.
  • Element can have element content, Mixed content, simple content and may be empty content.
  • Element can also have attributes like HTML.
  • In XML, attribute values must always represented in quotes.

Below is the sample studentsdetails.xml file.

<? xml version=”1.0” encoding="iso-8859-1"?> 
  <school name=”abc”>
    <studentdetail >
      <name> xxx </name>
      <regno> 123 </regno>
      <place> Coimbatore</place>
      <name> yyy </name>
      <regno> 124 </regno>
      <place> Coimbatore</place>

In this, school is the root node and it contain attribute name. Parent element is studentdetail. The child nodes are name, regno and place.

XML Declaration:

Very first thing in XML file is xml declaration. In XML file, the first line will be the xml declaration. It defines the version and the character set encoding used in student details.

<? xml version=”1.0” encoding="iso-8859-1"?> 


How to add a comment Line in XML?

Below is the syntax for comment line:

  <! -- This is a comment --> 

   1. It will not come in the top of your document.
   2. Nesting of tags is not possible.
   3. Comments cannot occur within tags.
   4. Don’t use the two dashes any where in the comments.
   5. Should be well formed then only it will ignored by the parser.

Naming Convention:

   1. Letters, Numbers, and other characters can be used in names.
   2. Names should not start with a number or special character.
   3. Splitting the names with space is not possible.

XML tags:

Tags are used to markup elements. XML tags are indicates the opening and closing of an element. There are two types of tags

Opening tag <element> 
Closing tag </element>


Below is the opening and closing tags of the above studentsdetails.xml file

<studentdetail> Opening tag
</studentdetail> Closing tag



Entities are variables used to define common text. Entities are expanded when a document is parsed by an XML parser.
Below is the predefined entities in XML:

 Entity References    Character
     &lt;                         <
     &gt;                        >
     &amp;                      &
     &quot;                     “
     &apos;                     ‘ 


XML Attributes:

  • Attributes provide additional information about the elements.
  • XML elements can have attributes in the start tag.
  • Attribute values must always represented in quotes.

Disadvantage of XML Attributes:

  • XML attribute cannot contain multiple values.
  • Attribute cannot describe structure.
  • Attributes are difficult to manipulate by program codes such as Vb.Net, C#, VC++ etc.
  • Attribute values are not easy to parse against DTD.

I hope this will help for beginners.

Like this article? Bookmark and Share:

Most viewed Articles

User Comments

  Re :What is XML?   
Posted by Spidy
on 3/3/2011 7:29:54 PM
Points : 10

Nice article for the beginners.


Submit feedback about this article

Please sign in to post feedback

Latest Posts