R4R provide basic XML Tutorials concept with
XML Examples .
Through R4R you can develop XML programming concept. R4R provide
XML Interview Questions with answers.R4R provide XML Languages study materials in easy way.
Introduction Of XML:
XML (eXtensible Markup Language) is a specification developed by the World
Wide Web Consortium (W3C).it is very flexible text format derived from SGML (ISO
8879). Originally designed to meet the challenges of large-scale electronic
publishing, XML is also playing an increasingly important role in the exchange
of a wide variety of data on the Web and elsewhere. It is a markup language much
like HTML used to describe data. In XML, tags are not predefined. A user defines
his own tags and XML document structure like Document Type
Definition (DTD) , XML Schema to describe
the data. Hence it is self-descriptive too .There is Nothing Special About XML
It is just plain text with the addition of some XML tags enclosed in angle
brackets. In a simple text editor, the XML document is easily visible .
Document Type Definition :Document Type
Definition (DTD) defines the legal building blocks of an XML document. It
defines the document structure with a list of legal elements and attributes. A
DTD can be declared inline inside an XML document, or as an external reference.
XML Schema :XML Schema is an XML-based alternative
to DTDs. It describes the structure of an XML document. The XML Schema language
is also referred to as XML Schema Definition (XSD).
"Well Formed" :XML document is a document that
conforms to the XML syntax rules.
"Valid" XML document is a "Well Formed" XML
document, which also conforms to the rules of a Document Type Definition (DTD)
History Of XML:
XML was developed to overcome the shortcomings of its two predecessors,
HTML and SGML which were both very successful markup languages, but which
were both restricted in certain ways.
SGML, the international standard for marking up
data, has been used since the 1980's. SGML is an extremely powerful and
extensible tool for semantic markup which is particularly useful for cataloging
and indexing data. Like XML, SGML can be used to create an infinite number of
markup languages and has a host of other resources as well. However, SGML is
complex, especially for the everyday uses of the web. Moreover, SGML is
expensive. Adding SGML capability to a word processor could double or triple the
price. Finally, the commercial browsers do not intend to ever support SGML.
HTML on the other hand was free, simple and widely
supported. HTML was originally designed to provide a very simple version of SGML
which could be used by regular people. However, HTML had serious defects.
XML So in 1996, discussions began which focused on how to define a markup
language with the power and extensibility of SGML but with the simplicity of
HTML. The World Wide Web Consortium (W3C) decided to sponsor a group of SGML
gurus including Jon Bosak from Sun. Essentially, Bosak and his team did to SGML
what the Java team had done to C++. All of the non-essential, unused, cryptic
parts of SGML were sliced away. What remained was a lean, mean marking up
machine: XML. The specification of XML (written mostly by Tim Bray and C.M.
Sperberg-McQueen) was only 26 pages as opposed to the 500+ pages of the SGML
specification! Nevertheless, all the useful things which could be done by SGML,
could also be done with XML.
Over the next few years, XML evolved, drawing from the work of its sponsors and
the work of developers solving similar problems such as Peter Murray-Rust who
had been working on CML (Chemical Markup Language) and the consortium of folks
working on MathML. By mid 1997 The eXtensible Linking Language XLL project was
underway and by the summer of 1997, Microsoft had launched the Channel
Definition Format (CDF) as one of the first real-world applications of XML.
Finally, in 1998, the W3C approved Version 1.0 of the XML specification and a
new language was born.
Why Is XML So Important?
There are number of reasons that contributes to the XML's
increasing acceptance , few of them are:
- Plain Text
- Data Identification
- Universally Processed
- Hierarchical Approach
- Inline Reusability
Architecture Of XML:
A basic architecture of an XML application using DOM is presented:
In This Figure A parser reads the XML file and builds a DOM document to match
the XML file. From that point until a save is performed, all interaction between
the application and XML hits the DOM document rather than the corresponding XML
file. It interesting to note that almost all XML parsers use SAX. Before you
build a DOM document you must detect events such as the start of an element
(start tag encountered), end of an element (end tag encountered) and/or a new
attribute (name followed by equal sign followed by quoted string encountered).
DOM can be thought of as an extra abstraction to lessen the programmer workload, at the expense of memory usage.
Modifications are made directly to the DOM document. Elements can be added,
deleted, renamed, and rearranged. Text nodes can be added, deleted or changed.
Elements can be moved either within the same level, or promoted or demoted to
Advantage of XML:
- It is text-based.
- It is platform-independent.
- It manifests as plain text files.
- Integrating with Existing Data Types
- It supports Unicode (allowing information in any language).
- It can represent data structures: records, lists and trees.
- It is based on international standards.
- The hierarchical structure is suitable for most types of documents.
- It makes parsing algorithms simple, efficient, and consistent. .
Difference Between Html and XML:
- XML was designed to describe data and to focus on what data is. HTML was
designed to display data and to focus on how data looks .
- HTML is about displaying information, while XML is about describing
- HTML is presentation language where as XML is not either a programming
language or a presentation language. It is used to transfer data between
applications and databases.
- HTML is not case-sensitive where as XML is case-sensitive.
- In XML it is mandatory to close each and every tag where as in HTML it is
- In XML, Data is stored in separate XML files but in HTML, it is stored
inside the files.
- White Spaces is preserved in XML files.
- To display HTML, we used CSS .In XML, we used XSL.
Relation Between SGML And XML
XML is a real subset of SGML.The most important diffrence is that output
spesification is not defined by SGML, but it is fixed in XML.
Importance Feature Of XML:
- XML files are text files, which can be managed by any text editor.
- XML is very simple, because it has less than 10 syntax rules.
- XML is extensible, because it only specifies the structural rules of tags. No
specification on tags them self.
Show All Comments
- Syntax is redundant or large relative to binary representations of similar
- The hierarchy schemata can be limiting
- Syntax is verbose relative to other alternative 'text-based' formats.
- More difficult, demanding, and precise than HTML
- It does not support data types, such as 'integer', 'string', 'boolean', and so
- Lack of browser support/end user applications
- The hierarchical model for representation is limited in comparison to an
object oriented model.
- Namespaces are problematic to use and support