Characteristic and use of XML

XML carries data in self-describing, user-defined tags: platform-neutral, presentation-free, and strict, which is why the fest's event list can feed the website and the app from one file.

9 min read · 10 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

The event list lives in 4 places

FestConnect, the fest site you built in BCA305-01, has a problem of success. The event list is hardcoded in the home page's HTML. And in the schedule page. And the registration page. And the Android app from BCA305-02 carries its own copy.

The fest committee changes Garba Night's venue, and 4 copies must be edited; miss one and students walk to the wrong ground.

Data wants to live ONCE, in a form everything can read. This unit's answer is XML.

Theory

Labelled dabbas, not printed plates

An HTML page is a printed plate: food arranged for one table, presentation included.

An XML file is a tiffin of labelled dabbas: each container says what is inside (<venue>, <time>), nothing says how to serve it. The website plates the same dabbas one way, the app another, and tomorrow's new consumer (a notice-board display?) helps itself too.

XML carries; consumers present.

Theory

XML, formally

XML (eXtensible Markup Language) is a markup language for storing and transporting data in self-describing text.

Characteristics the exam lists:

  • User-defined tags: YOU invent <event>, <venue>; nothing is predefined (that is the eXtensible)
  • Self-describing: the tag names document the data
  • Platform and language independent: plain text; any OS, any language parses it
  • Separates data from presentation: no fonts, no colours, only meaning
  • Strict: rules (next lessons) that parsers refuse to bend

Practical

events.xml: the fest's single source of truth

<?xml version="1.0" encoding="UTF-8"?>
<events>
  <event id="1">
    <name>Garba Night</name>
    <venue>Main Ground</venue>
    <time>19:30</time>
    <seats>350</seats>
  </event>
  <event id="2">
    <name>Coding Contest</name>
    <venue>Lab 2</venue>
    <time>10:00</time>
    <seats>60</seats>
  </event>
</events>

At a glance

HTML vs XML (the standard comparison)

AspectHTMLXML
PurposeDISPLAY dataCARRY and store data
TagsPredefined (<h1>, <p>)User-defined (<event>, <venue>)
RulesForgiving: browsers guessStrict: parsers refuse errors
CaseInsensitiveSensitive: <Name> is not <name>
PresentationBuilt inNone: consumers decide

Quiz

What is XML primarily designed to do?

  1. Display data attractively in the browser
  2. Store and transport data in self-describing form
  3. Replace HTML for building web pages
  4. Compress data for faster networks
Show the answer

Store and transport data in self-describing form

XML is the labelled dabba: it carries data with meaning and says nothing about looks. Option A is HTML's job, and display-vs-carry is THE exam distinction between the 2. Option C misreads their relationship: they are colleagues with different jobs, and FestConnect uses both (HTML to show, XML to store). Option D is almost backwards: self-describing tags make XML files LARGER than raw data, a price paid willingly for readability and independence.

Think first

You have written XML for a whole semester

Before tapping: where in BCA305-02, the Android subject, were you already writing XML files without this unit's theory?

Show the answer

Everywhere: every layout file (activity_main.xml, the LinearLayouts and TextViews) and the AndroidManifest.xml are XML documents: user-defined-by-Google tags, one root element, strict nesting, attributes in quotes. Android chose XML for exactly the characteristics this lesson listed: self-describing, platform-neutral, data-not-presentation. So the rules in the next 4 lessons are not new discipline; they are the grammar you were already obeying, now named.

Watch out

Two first-week misconceptions

"XML is advanced HTML": no. Different purpose (carry vs display), different tag origin (yours vs predefined), different strictness. The comparison table is the answer scheme; learn its rows.

"The browser will fix my XML": browsers rescue broken HTML daily, and that mercy trained bad habits. XML parsers REFUSE ill-formed documents outright: one unclosed tag and the whole file is rejected. Strictness is the feature: machines exchanging data cannot afford guesses.

Theory

Where this unit goes

events.xml is now FestConnect's single source of truth, and the rest of the subject builds the machinery around it: jQuery (Unit 2) to make pages react, JSON (Unit 3) as XML's leaner modern rival for the same job, AJAX (Unit 4) to fetch the data without reloading, and Node.js (Unit 5) to serve it. First, though, the grammar: exactly what makes an XML file legal, starting with declarations, tags and elements next lesson.

Summary

Key takeaways

  • XML stores and transports data in self-describing, user-defined tags; it never dictates presentation.
  • eXtensible = you invent the tags: <event>, <venue>, whatever the data needs.
  • Plain text, platform and language independent: one file feeds the site, the app, and whatever comes next.
  • HTML displays with predefined, forgiving tags; XML carries with user-defined, strict ones.
  • Uses: data storage, exchange between systems, configuration (Android layouts and manifest), RSS, SVG.
  • Parsers refuse ill-formed XML: strictness is what makes machine exchange trustworthy.
  • Memory hook: HTML is the plate, XML is the labelled dabba.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Introduction of XML

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Characteristic and use of XML · Web Designing-2 (option A) · Gri-Learn