What is XML?


 

What is XML?

Learn what is XML and how to create XML file.

Learn what is XML and how to create XML file.

What is XML?

In the first section of XML tutorials we will learn the basics of XML and then write our first xml document. After completing this section on "What is XML?" you will be able understand the XML document and create well formatted XML document.

What is XML Document?

Some facts about XML:

  • XML file is simple text file with .xml extension.
  • XML file is used mainly to store and transport data
  • XML is also used by the applications to store configuration data
  • Many programming languages such MathXML, SVG, SMIL, XHTML etc. are created using XML
  • XML is markup language much like HTML
  • XML is self descriptive and it contains the description of the data along with the data
  • The eXtensible Markup Language is W3C Recommendation

The eXtensible Markup Language or XML for short is a text document used mainly for distributing the data on internet between different application. It's a structured document for storing and transporting the data; mainly used for the interchanging the data on internet. For example travel booking application may send the data in xml format to the credit card processing gateway for processing the data. In return the credit card processing process may also return the success or failure result to the calling application in the XML format.

XML is also used by the applications to store the configuration information. For example Java web application uses web.xml file to declare various components such as Servlets, Filters etc. for the web application.

Here is simple example of XML file:

<Invoice>
   <to>ABC Company</to>
   <from>XYZ Company</from>
   <heading>Invoice for Programming book</heading>
   <data>
     <product>XML Book</product>
     <cost>US$100</cost>
   </data>
</Invoice>

This file must be saved with .xml extension. We are saving this file as invoice.xml. If you open the invoice.xml file in firefox it will display the xml file structure as show below:

Click here to view invoice.xml

XML and HTML

HTML contains the HTML tags such as <p>, <body>, <input> etc. and the data also. HTML is developed to design the web pages for the website. It contains the data as well as the information for displaying the data on the web browser.

Where as XML just contains the data in proper tags. It does not contains the information for data presentation. If you have an XML file you will have to write separate logic to present the data on browser or other format. XML is designed to transport and store the data. XML is not a replacement of HTML. XML can used in server-side program such as JSP and then parsed and display the data into html format.

 

Ads