EXTENSIBLE MARKUP LANGUAGE (XML)

There are several languages derived from XML such as MathML and WML. MathML is a markup language for the representation of mathematical formulae and scientific data. Similarly, WML (Wireless Mark Language) is a markup language used for web applications that can be accessed by using a cellular phone.
Differences between HTML and XML:
A markup language like HTML provides tags to indicate how a file should look when displayed on a web page. Using HTML, we can create web pages easily and effectively. HTML is mainly used for data presentation using a fixed set of tags.
XML, which is the extension of HTML was developed by World Wide Web Consortium (WCC) for the purpose of extending the features of mark-up languages from presentation to document processing and data interchange. XML was designed to ease data exchange over the Internet. XML is mainly used for data description and definition.
Components of XML document:
XML is a device-independent mark-up language. It provides the structure for organizing and arranging the data in a hierarchical order that can be recognized by different kinds of computers. The data maintained by XML are available to devices ranging from mainframe computers to mobile phones.
The following are the various components of a XML document:
1. Processing Instruction (PI)
2. Tags
3. Elements
4. Content
5. Attributes
6. Entities and
7. Comments
The following is an example for a XML document containing data that belongs to a product having product id P001:
Program: Product.xml that describes and stores a Product detail
The output of the above XML file when it is opened in a web browser like IE is as follows:
The above XML describes a product with product id P001. It describes two attribues of the product: description and price. The description contains some text about the product and the price contains some value ($20.00) that specifies the cost of the product. The root element of this XML document is named as PRODUCTDATA that acts as a container element for the product P001.
Structuring Data:
XML permits document authors to create mark-up for virtually any type of information. XML documents contain only data, not formatting instructions, so applications that process XML documents must decide how to display the document data. XML elements describe the data contained in those elements, so XML processing programs can search, sort, manipulate and render XML documents.
Processing an XML document requires a software program called a XML Parser (or a XML Processor). Parsers check a XML document’s syntax and enable software programs to process marked-up data. XML parsers can support the Document Object Model (DOM) or the Simple API for XML (SAX).
A XML document optionally can reference a document that defines the structure of it. This document is either a Document Type Definition (DTD) or a Schema. When a XML document references a DTD or Schema, the parser reads the DTD/Schema and check that the XML document follows the structure that the DTD/Schema defines.
XML Element:
With XML, document authors can create elements that describe data precisely. Tags delimit the start and end of each element. Every XML document must contain exactly one root element, which contains every other element. The lines that precede the root element are the XML prolog. Attempting to create more than one root element is an error.
XML elements can have attributes defined for them just like the attributes defined for HTML tags. These attributes are given by its author to describe it with a name and other details. XML element and attribute names can be of any length and may contain letters, digits, underscores, hyphens and periods. However, XML names must begin with either a letter or an underscore. Using either a space or a tab in a XML element name or attribute name is an error.
Any element that contains other elements is a container element. Elements inside a container element are child elements (or children) of that container element. IE displays minus (-) and plus (+) sign next to all container elements to hide/view the children under them.