BIT251 ยท 2080 ยท 5 marks
What is the use of XML? Why is it called extensible, justify with example.
What is the use of XML? Why is it called extensible, justify with example. [5]
Quick answer
XML (eXtensible Markup Language) is a markup language designed to store, transport, and describe data in a structured, human-readable, and machine-readable format. It is a W3C recommended standard.
XML: Uses and Extensibility
What is XML?
Uses of XML
| Use | Description |
|---|---|
| Data Storage | Stores structured data in plain text files (e.g., configuration files) |
| Data Exchange | Transfers data between different systems and platforms (e.g., web services, APIs) |
| Web Development | Used in technologies like XHTML, RSS, SOAP, and AJAX |
| Database Communication | Acts as a medium to exchange data between databases |
| Document Representation | Represents documents with complex structure (e.g., Microsoft Office .docx) |
| Configuration Files | Many applications use XML for configuration (e.g., web.xml in Java) |
Why is XML Called "Extensible"?
XML is called extensible because:
Unlike HTML, which has a fixed, predefined set of tags, XML allows users to define their own custom tags according to their specific needs.
There is no fixed vocabulary in XML. You can create any tag name that is meaningful to your application. This ability to extend and define new markup makes it "extensible."
Justification with Example
HTML (NOT extensible - fixed tags only):
<p>John</p>
<b>Engineer</b>
You cannot create
<student>or<rollno>in HTML.
XML (Extensible - user-defined tags):
Suppose a school wants to store student data. They can define their own tags:
<?xml version="1.0" encoding="UTF-8"?>
<school>
<student>
<rollno>101</rollno>
<name>Ram Sharma</name>
<faculty>BSc CSIT</faculty>
<semester>5</semester>
</student>
<student>
<rollno>102</rollno>
<name>Sita Thapa</name>
<faculty>BSc CSIT</faculty>
<semester>5</semester>
</student>
</school>
Now suppose a hospital needs to store patient data. They define completely different tags:
<?xml version="1.0" encoding="UTF-8"?>
<hospital>
<patient>
<patientid>P001</patientid>
<name>Hari Bahadur</name>
<disease>Fever</disease>
<doctor>Dr. Laxmi</doctor>
</patient>
</hospital>
Key Observations:
- Tags like
<rollno>,<faculty>,<patient>,<disease>are not predefined anywhere. - The user created them based on their own requirements.
- Both examples are valid XML despite having completely different tag sets.
Summary
XML is called extensible because it does not restrict users to a fixed set of tags. Users can invent, define, and use their own tags to describe any kind of data, making XML flexible and adaptable to any domain or application.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.