You are here

Extensible Markup Language (XML)

19 January, 2016 - 16:44

HTML is the most successful markup language of all time. You can view the simplest HTML tags on virtually any device, from palmtops to mainframes. Given the success of HTML, why did the W3C create XML? To answer that question, take a look at Figure 1.8.

Figure 1.8 Sample HTML code

HTML was designed to be user-friendly. Without any special software, you and I can view the code in Figure 1.8 in a text editor and understand that its content refers to the movie Fist of Fury and its related information, such as the country of origin, year of release, leading actors and director.

While the tags in this document tell the browser that this document is made up of headings, paragraphs and lists, it doesn’t tell the browser what the information is. Humans have the native intelligence to understand the meaning of this document, but computers don’t. Now why would this be a problem? Well, the Web would be a lot more useful if computers could also extract information directly from webpages, without waiting for any human assistance to help them understand and process the contents.

XML is a markup language which allows you to create your own tags, which can then be used to produce self-describing documents. Unlike HTML, which is a language just for creating webpages, XML is a language that lets you create other languages, hence the term ‘extensible’ in its name. By designing your own customized markup language, you are free to create and attach your own markup tags to the data in your own documents.

Figure 1.9 shows the same code fragment shown earlier. This time, the HTML tags have been replaced with XML tags that describe the meaning of the data instead. By using XML to describe the meaning of data found on webpages, you and I can make it easier for computers to process the information on these pages.

Figure 1.9 Sample XML code

XML also acts as the foundation for Web protocols.

You will now try viewing XML data within your Web browser in the next activity. Note that XML files end with the ‘.xml’ file extension. Like HTML, they are also text-based, which means you can open and edit them using a regular text editor such as Notepad on Windows and vi or emacs on UNIX.