XML Syntax

By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022

Rule 1: Root:  Root Element is the parent of all other nodes. Example:
<root>   <First child>     <First sub child>.</First sub child>     <Second sub child>.</Second sub child> </First child> </root>

Rule 2: XML Pro log: XML prolog is optional. If XML exists then  XML must come first in the document. Example:
<?xml version=”1.0″ encoding=”UTF-8?>

Rule 3: Case Sensitivity: XML tags are case sensitive. Example:
<author> sameed </author> <AUTHOR> sameed <AUTHOR>
In this example both tags representing different tags.
Rule 4: Attributes values must be qouted. Example:
Wrong Practice Right Practice
<book date=12/11/2007>   <title>Book On XML</title> </book> <book date=12/11/2007>   <title>Book On XML</title> </book>

Rule 5: Comment: Comment are used to give some opinion for better understanding. Example:
< ! −− 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
 

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials