XML & XML
Submitted By: Himanshu Soni
Roll No: 1301410040
Subject: Web Technolgy
Introduction to XML
HTML Vs XML
Structure of XML Document
DOM & SAX
Introduction to XML
What is XML ?
XML is an acronym for “eXtensible Markup
XML is a markup language derived from
SGML (Standard Generalised Markup
It is used to store data in structured format.
HTML vs XML
HTML document formats and
displays web page data.
XML document carry data along
with their description.
Predefined tags (Predefined
Not have predefined tags.You
can create and define new tags
as per your needs.(Meta
May not have closing tag. Must have closing tag.
Not Case Sensitive. Case Sensitive.
Directly Viewable in browser. Viewable if proper Stylesheet
Structure of XML Document System
A style sheet presentation through CSS or XSL.
A grammer structure through DTD.
A semantics of data through XML file.
CSS or XSL
Structure of XML file
XML file has –
-a logical structure and
- a physical structure
It refers to different parts of
document i.e., how document is built.
It refers what document actually
-prolog (preface or introduction to XML document)
-data instance (the real or actual data)
Prolog Data Instance
An XMl declaration
A document type definition
Element types, tags and
<? xml version=“1.0” encoding= “UTF-8” standalone=“no” ?>
<? xml-stylesheet type=“text/css” href=“main.css” ?>
Document Type Declaration (DTD)
<! DOCTYPE rootElement SYSTEM DTD_File_Name.dtd>
<!– Listen Here -->
Spaces, tabs, linebreak
When a software program reads an XML
document and takes actions accordingly, this
is called processing the XML.
Any program that can read and process XML
documents is known as an XML processor.
An XML processor reads the XML file and
turns it into in-memory structures that the
rest of the program can access.
What is Parser?
The word parser comes from compilers. In a
compiler, a parser is the module that reads and
interprets the programming language.
Parsers are software components that decode XML
files on behalf of the application
There are two basic ways to interface a parser with
Architecture of XML Program
Divided into two parts:
• The parser deals with the XML file.
• The application consumes the content of the file through the
Here application can be very simple (such as printing information on
the screen), or quite complex (such as a browser or an editor)
Using an object-based interface, the parser explicitly builds
a tree of objects that contains all the elements in the XML
Tree-based parsers deal generally small documents
With an event-based interface, the parser does not explicitly
build a tree of objects.
Instead, it reads the file and generates events as it finds
elements, attributes, or text in the file.
There are events for element starts, element ends,
attributes, text content, entities, and so on.
Event-based parsers deal generally used for large
An event-based API
The Document Object Model (DOM) is an
application programming interface (API) for HTML
and XML documents.
It defines the logical structure of documents and
the way a document is accessed and manipulated
Programmers can build documents, navigate their
structure, and add, modify, or delete elements and
The API allows for constructing, accessing and
manipulating the structure and content of XML
Basically, DOM is object based parser
DOM Parser DOM TreeXML File
SAX (Simple API for XML) is an event-
driven algorithm for parsing XML documents.
SAX provides a mechanism for reading data from
an XML document.
SAX parsers operate on each piece of the XML
SAX parsing is unidirectional; previously parsed
data cannot be re-read without starting the
parsing operation again
SAX vs DOM Parsing: Efficiency
The DOM object built by DOM parsers is usually
complicated and requires more memory storage than
the XML file itself
A lot of time is spent on construction before use
For some very large documents, this may be
SAX parsers store only local information that is
encountered during the serial traversal.
Hence, programming with SAX parsers is, in
general, more efficient but difficult to implement
Benoit Marchal. XML by Example. 1 edition. QUE
(14 December 1999)
Pankaj Sharma. Introduction to Web Technology.
S.K. Kataria & Sons
Sumita Arora. Informatics Practices. Dhanpat Rai &
Co. (P) Ltd., Delhi 2010