Getting Started with XML


Extensible Markup Language, commonly known, as XML is a markup language recommended by W3C (World Wide Web Consortium -- the governing body for Web Standards). XML is a subset of SGML (Standard Generalized Markup Language) that became popular for designing Web document. XML is used for creating documents, which contain structured information and defines standard way to use markup in the document. Document that includes content (words, image etc.) and other indicators like (heading, footnote, caption, database table etc.) is known as "structured information". XML plays ultimate role to create and manage "structured information" of electronic documents.


Apparently, XML is quite similar to HTML (Hyper Text Markup Language), which is another subset of SGML and is used for creating World Wide Web pages. Objectives of XML and HTML are different and both have unique set of goals. With XML you can create customized tags to describe the content of the webpage. Compared to HTML, XML is case sensitive and use "white spaces" and special characters very carefully in the document.

Since the goals are different for HTML and XML, therefore it can be said that XML is not a substitute for HTML. While HTML is used mainly to manage the display or appearance of data, XML on the other hand, is used to describe, transmit and manipulate data over the Web. HTML tags are predefined and provide less flexibility to the users to manage structured information. By using XML users can customize the tags based on their needs -- they can define their own tags as well as the structure of the document. Finally, it can be said that HTML is the foundation of electronic document while XML is the future.

10 Goals of XML

Following are the ten major goals of Extensible Markup Language:

  • To provide straightforward and Internet-friendly approach so that viewers can easily access XML documents. This is possible by making XML browsers widely available across the globe.
  • To support wide array of applications. Though the basic focus of XML is on helping users to create structured documents but provides support to useful applications -- browsing, authoring, content analysis etc.
  • To offer SGML (Standard Generalized Markup Language) compatibility, XML is designed logically to support existing standards as well as to solve the problem of sending structured information over the Internet.
  • To allow simple way of creating programs to process XML.
  • To minimize the number of optional features. It is observed that the number of optional features is closely related to compatibility problems. Thinking in this line, XML provides almost zero optional features, especially during the time of sharing a document and allows a trouble free process.
  • To provide logical and legible document structure. Even instead of XML browser one can easily distinguish the actual content from the XML tags in an XML document and understand the purpose of that structured document.
  • To offer fast way of preparing XML design.
  • To provide formal and to the point designing approach.
  • To provide easiest way of creating and editing XML documents. Other than sophisticated editors you can create or edit XML documents in simple text editor with the help of Perl, Shell or any other scripting language.
  • To give minimum importance to the short structure of the document. Terseness is a common feature of several SGML languages but there are many editors, which provide facilities to define shortcuts when creating the text.

Advantages of XML

XML is used to exchange information over the Internet. Following are some remarkable advantages that made XML popular across the globe:

  • It is easy to read and understand XML documents. If you have little knowledge on HTML then you can efficiently create XML document by using XML codes. Each tag of XML document describes the type of data. XML also provides the facility to customize tags in order to define the types of data, which are enclosed by the tags.
  • Compatibility and portability are two major features of XML. XML is 100% portable and regardless of platform supports applications, which can process XML. Irrespective of the operating system of your computer, if you have any text editor you can create an XML document with little effort. Today, with the growing use of XML you will get several types of XML parsers for all the major operating systems. Also there are several object-based parser components available in the market for XML.
  • "Customized tag" is another advantage of XML. In general customized tags, which are not pre-defined, are used to make sense to the developers and other users. XML provides the flexibility to create your own tags as well as allow customized tags created by others in your own XML document.

Features of XML

Compared to Hyper Text Markup Language (HTML), Extensible Markup Language (XML) supports tree-based structure to describe information. Character is the fundamental unit of XML and structures combination of characters will form XML document. Each document may contain several entities, which are combination of a portion of characters, stored in a text file.

You can use XML to separate data from a HTML document. In general HTML takes care of the display, specially the design of the webpage. You can store data directly inside the HTML document or can store in a completely separate XML file. It is advantageous to follow the technique of using separate XML. By this you can easily make any changes in the layout of the webpage without making any change in the data, which is stored inside that webpage. Similarly, you can also change the data directly in the XML file without making any change in the layout of the webpage.

XML has become popular for exchanging financial information over the Internet. Applications developed by XML are used widely to provide effective support in B2B (Business to Business) processes to carry financial data from one node to another. Moreover, using XML file you can store data in a plain text format. This feature comes with sharing facility. Since XML is independent of software and hardware, therefore you can create XML document that is compatible with different applications and easily share that information irrespective of the hardware and operating systems of other users.

Have you ever thought about storing data in a plain text file? XML comes with this facility. Using XML you can easily store data in files and can retrieve data from that file by using necessary application. You can use XML to create application to store and to retrieve information from the database, but in general, people are using XML is to display data in a webpage.

XML Syntax:

The syntax rules of XML are simple and easy to understand. Let us study the following XML document:

<?xml version="1.0" encoding="ISO-8859-1"?>
<body>Mail me immediately</body>

In the above example, the first line "<?xml version="1.0" encoding="ISO-8859-1"?>" is the declaration of XML that contains XML version "1.0" and character encoding "ISO-8859-1", which is used in the document.

The second line defines the root element of the document. A root element can be heading, caption, footnote, database etc. According the above example, the document is a note. All the contents are written within the tags - <note> and </note>.

XML Elements:

Apart from declaration and root element, XML document contains child elements, which are written inside root.

<body>Mail me immediately</body>

Above statements are child elements of the XML document. Child elements which are written within <note> and </note> tags are extensible. For example, if you want to mention date and time, just type following line with the above four child elements.

<body>Mail me immediately</body>

Each element is written within a pair of opening and closing tags. Developers can customize the tags to define the element. Each element has content that can be element content, mixed content, simple content or empty content.

Let us consider another example of XML document:

<name>ABC, Inc.</name>
Organizational Units of ABC, Inc.
Managers of Organizational Units:
<para>Mr. Mike Williams -- Manager (Marketing)</para>
<para>Mr. James Francis -- Manager (Finance)</para>

In the above example, <name>, <organizational_unit> and <manager> are the child elements of <company>. The outcome of the above XML document is:

ABC, Inc.
Organizational Units of ABC, Inc.

  • Marketing
  • Finance

Managers of Organizational Units:

  • Mr. Mike Williams -- Manager (Marketing)
  • Mr. James Francis -- Manager (Finance)  

XML Attributes:

Value of an element is called "Attribute". Attributes are defined in the starting tag to offer additional information about the element. Following are the examples of some XML attributes:

<img scr="company.jpeg">
<a href= "abc.asp">
<file type="jpeg">company.jpeg</file>

XML Browsers

It is observed that most Internet Browsers support Extensible Markup Language (XML). Following are some XML browsers:

Internet Explorer 6.0: Internet Explorer 6.0 provides full support to XML and its features such as: Namespaces, CSS, Style sheet and XSLT 1.0. Moreover Internet Explorer 6.0 has in-built XML Parser 3.0.

Internet Explorer 5.0: Internet Explorer 5.0 supports XML but the XSL (Extensible Stylesheet Language) part is not compatible with this browser. XSL looks after the presentation of XML documents and translates XML documents into another format.

Firefox 1.0.2: This browser provides complete support to XML and XSLT (Extensible Stylesheet Language Transformation). XLST (XML + CSS) is a language transforming XML documents into another XML documents.

Mozilla 1.7.8:This is another XML browser that provides complete support to XML documents. Mozilla 1.7.8 comes with "Expat" that supports XML-prasing, Namespaces and XSLT.

Opera 8: Opera 8 is another XML browser that supports both XML and Extensible Stylesheet Language Transformation (XSLT).

Netscape 6: Even you can use Netscape 6 as an XML browser. Like other XML browsers, Netscape 6 also supports major features of XML.

Add Feedback