CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

XML: An Introduction

XML – eXtensible Markup Language is pretty famous standard and widely used for exchanging data over the network.

In this article we are going to discuss about XML standard and it’s history.

Before discussing about XML standard let’s have a brief look into it’s history.

History of XML

In earlier days, especially when the Internet was introduced; electronic devices had to communicate with each other using their own format. And, it was painful to maintain all these formats and whenever the new format introduced or modified format released, all devices had to upgrade the software to understand the new or modified format.

To overcome this problem W3C (Word Wide Web Consortium – an international community which gives web standards as a set of principles. W3C is an Open Source Organization.) introduced SGML (Standard Generalized Markup Language). SGML is an advanced version of GML (Generalized Markup Language – An IBM product).

SGML is a markup language with a structured declaration. SGML contains a declaration statement and DTD (Document Type Definition) file for documenting the rules. By following the DTD we need to prepare the SGML. In SGML every element must be surrounded with opening and closing tag. Elements are case sensitive in SGML.

SGML is very large and complex. Developing SGML is a complex because of it’s structure. To overcome this, W3C introduced another standard, XML – eXtensible Markup Language. XML is  a tailored version of SGML.

Why XML?

As SGML is very complex and difficult to understand, there was a need to look out for a simple and easy to understand markup language and it should be agreed by majority of industries to exchange the data over the network. Hence XML. And because:

  • XML is a lightweight compare to SGML and easy to maintain.
  • XML is widely used for exchanging the data over the network. All industries follows XML is a standard for exchanging the data.
  • XML is a self descriptive language i.e., we can create our own languages. It is used as a data transport or data carrier.
  • XML is an interoperable language i.e., it can be interpreted by any other person in the world same as the original. We no need to change the XML file into the corresponding machine understandable language.
  • XML is a universal understandable language and it is accepted by all industry experts.
  • XML reduces the burden of writing the environment specific code. In other way that, now a day’s all frameworks in Java are using XML for configuring the components and those are technically called as configuration files or descriptor files.
  • XML is platform independent file; because it works with all platforms. Some files like “.DOC” are works with only Windows Operating Systems.
  • XML supports all possible data types.

And XML is a tag based language; so, the data is enclosed within the tags; thus extracting the data is easy. There are no predefined tags in XML. All tags are declared in DTD defined by the vendor. We will discuss about DTD in our upcoming articles.

In XML, data is organized in a hierarchical manner; so, it is very helpful to understand. XML is also called as tiny database.

Let’s take a simple XML example. Below is the XML declaration which contains an “employee” record. Each employee record contains the fields “empnum”, “name”, “dob” and “doj” as XML tags. Each field contains the data.

<?xml version="1.0" encoding="UTF-8"?>
<employee>
   <empnum>1</empnum>
   <name>Adam</name>
   <dob>20-October-1984</dob>
   <doj>8-January-2010</doj>
</employee>

The very first line tells the version of the XML. And “UTF-8” tells, this XML document uses Unicode character set; that means XML contains Unicode characters. Later XML parsers will use this information while parsing XML files.

So, above code contains different tags. But we need to validate this data and the tags used in the XML file. Based on what? How the parsers will validate this data? That is the reason we need to provide Data Type Definitions for XML file. For writing a well formed XML we need DTDs. If the element is not defined in DTD and used in XML file; parsers will throw an error.

We will discuss more about DTDs and XML in our upcoming articles.

Thank You.

XML: An Introduction

2 thoughts on “XML: An Introduction

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top