XML is the abbreviated form of Extensible Markup Language.
XML is a markup language that defines the set of rules for encoding the documents that can be read by both a human and a machine. XML is a set of codes, or tags, that describes the text in a digital document. The most common and popular markup language is Hypertext Markup Language i.e. HTML, which is used in the formatting of Web pages.
XML is designed to store and transport data.
Let us take an example of an XML document.
<body>Don’t forget me this weekend!</body>
The first tag in an XML document is the root element used as start and end tags. Inside the root, the element is the child element which may or may not contain its sub-child element.
The XML is self-descriptive, describing the sender information, receiver information, heading, and message body through its tags. Hence, when the data arrives, there is no need to pre-build the structure of the code to store the data; it can be dynamically interpreted by the XML.
The technologies which support XML documents are XHTML, XQUERY, XSD, SOAP, ETC. A well-designed XML document can be verified against DTD or Schema. To verify an XML document, it must begin with the XML declaration, have one unique root element, should contain matching start and end tags, and the elements should be properly nested.
XML and HTML (XML versus HTML)
XML code, which is formally recommended by the World Wide Web Consortium, is similar to the HTML (full form of Hypertext Markup Language). Both the languages contain markup symbols to describe the page of file contents. The difference between them is that XML is designed to transport and store data not display it, whereas HTML code describes the Web page content only in terms of how to display it.
Unlike the HTML tags, the XML tags are not pre-defined, they must be defined. It takes a lot of work to edit the HTML each time the data changes. So, in dynamic data, you can store the data into separate XML files and focus on the HTML/CSS for display and layout. In this way, if there is a change in HTML, the underlying data need no more changes.
Advantages of XML
- The biggest advantage of using XML is it is very simple.
- It can take large pieces of information and can consolidate them into meaningful pieces that structure the information.
- XML generally stores the data in simple text format and provides a software-hardware independent way of storing, sharing, and retrieving data.
- Data are made available to all kinds of “reading machines” like people, computers, voice machines, news feeds, etc.
- Searching XML documents for <first-name> elements would give very less erroneous set of results.
Disadvantages of XML
- XML depends on HTML to be able to be read in a browser.
- It is backend technology for data storage and transmission, lacking rendering instructions.
- The file size is very large.
- Most programmers are not aware of the ways to parse XML files.
Hope you understood the meaning of XML, its features, how different it is from HTML, and the advantages and disadvantages of XML. If you still have any doubts or queries, do mention them in the comments section. We would try to answer and resolve them at the earliest.