XML Syntax

Rule 1:


Root Element is the parent of all other nodes.


  <First child>
    <First sub child>.</First sub child>
    <Second sub child>.</Second sub child> </First child>

Rule 2:

XML Pro log:

XML prolog is optional. If XML exists then  XML must come first in the document.


<?xml version=”1.0″ encoding=”UTF-8?>

Rule 3:

Case Sensitivity:

XML tags are case sensitive.


<author> sameed </author>

<AUTHOR> sameed <AUTHOR>

In this example both tags representing different tags.

Rule 4:

Attributes values must be qouted.


Wrong Practice Right Practice
<book date=12/11/2007>
  <title>Book On XML</title>
<book date=12/11/2007>
  <title>Book On XML</title>

Rule 5:


Comment are used to give some opinion for better understanding.


< ! −− this is comment − − >

Rule 6:

Starting and closing of tags:

  • Every tag should have starting and ending.
  • For example <author> is the starting of author tag and </author> is the closing of the author tag.
  • Early starting tag should be late closed and late started tag should be early close. Example is shown in the diagram below.

tags in html


Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.