Thursday, 17 January 2013

What is an XML File or XML Document? Why to use XML?

What is an XML File or XML Document? Why to use XML?

This article covers basics of XML. We will discuss some benefits and advantages of XML.

What is XML?

XML is Extensible Markup Language. XML is a specification developed by W3C. XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed with relatively little human intervention and exchanged across diverse hardware, operating systems, and applications.

In brief, XML offers a widely adopted standard way of representing text and data in a format that can be processed without much human or machine intelligence. Information formated in XML can be exchanged across platforms, languages, and applications, and can be used with a wide range of development tools and utilities.

Example of XML Document

<bag label="Glenns Food" storage-date="October, 2001">
  <item>Candy Bar</item>
  <bag label="Vegetables" storage-date="Oct 11 2001">
 <item>Carrot</item>
 <item>Lettuce</item>
  </bag>
  <bag label="Fruits" storage-date="Oct 13 2001">
 <item>Pear</item>
  </bag>
</bag>

Difference between HTML and XML

XML is similar enough to HTML in its actual format. But there are two fundamental differences:

1. Separation of form and content -- HTML mostly consists of tags defining the appearance of text; in XML, the tags generally define the structure and content of the data, with actual appearance specified by a specific application or an associated stylesheet.

2. XML is extensible -- tags can be defined by individuals or organizations for some specific application, whereas the HTML standard tagset is defined by the World Wide Web Consortium (W3C).  

Advantages of XML

1. Simplicity

Information coded in XML is easy to read and understand, plus it can be processed easily by computers.

2. Openness

XML is a W3C standard, endorsed by software industry market leaders.

3. Extensibility

There is no fixed set of tags. New tags can be created as they are needed.

4. Self-description

In traditional databases, data records require schemas set up by the database administrator. XML documents can be stored without such definitions, because they contain meta data in the form of tags and attributes.

XML provides a basis for author identification and versioning at the element level. Any XML tag can possess an unlimited number of attributes such as author or version.

5. Contains machine-readable context information

Tags, attributes and element structure provide context information that can be used to interpret the meaning of content, opening up new possibilities for highly efficient search engines, intelligent data mining, agents, etc.

This is a major advantage over HTML or plain text, where context information is difficult or impossible to evaluate.

6. Separates content from presentation

XML tags describe meaning not presentation. The look and feel of an XML document can be controlled by XSL style sheets, allowing the look of a document (or of a complete Web site) to be changed without touching the content of the document. Multiple views or presentations of the same content are easily rendered.

7. Supports multilingual documents and unicode

This is important for the internationalization of applications.

8. Facilitates the comparison and aggregation of data

The tree structure of XML documents allows documents to be compared and aggregated efficiently element by element.

9. Can embed multiple data types

XML documents can contain any possible data type - from multimedia data (image, sound, video) to active components (Java applets, ActiveX).

10. Can embed existing data

Mapping existing data structures like file systems or relational databases to XML is simple. XML supports multiple data formats and can cover all existing data structures and

11. Provides a 'one-server view' for distributed data

XML documents can consist of nested elements that are distributed over multiple remote servers. XML is currently the most sophisticated format for distributed data - the World Wide Web can be seen as one huge XML database.

No comments:

Post a Comment