Characteristic and use of XML

XML data ને self-describing, user-defined tags માં carry કરે છે: platform-neutral, presentation-free, અને strict, જે એટલે છે કે fest ની event list website અને app ને એક file થી feed કરી શકે છે.

9 min read · 10 cards · 2 checks

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


Theory

event list 4 places માં lives કરે છે

FestConnect, fest site જે તમે BCA305-01 માં build કર્યું હતું, તેની પાસે success ની problem છે. event list home page ના HTML માં hardcoded છે. અને schedule page માં. અને registration page માં. અને Android app જે BCA305-02 માં હતું તે તેની own copy ને carry કરે છે.

fest committee Garba Night નું venue ને change કરે છે, અને 4 copies ને edit કરવું પડે છે; એક ને miss કરો અને students wrong ground પર walk થાય છે.

Data એકવાર live થવા માંગે છે, એવા form માં જે everything read કરી શકે. આ unit નો answer XML છે.

Theory

Labelled dabbas, printed plates નહીં

HTML page એ printed plate છે: food arranged for one table, presentation included.

XML file એ tiffin છે labelled dabbas નું: દરેક container કહે છે કે અંદર શું છે (<venue>, <time>), કંઈ કહેતું નથી કે કેવી રીતે serve કરવું. website same dabbas ને એક રીતે plate કરે છે, app બીજી રીતે, અને tomorrow નો new consumer (notice-board display?) તેને પણ help itself કરે છે.

XML carry કરે છે; consumers present કરે છે.

Theory

XML, ઔપચારિક રીતે

XML (eXtensible Markup Language) એ markup language છે data ને store અને transport કરવા માટે self-describing text માં.

characteristics જે exam lists કરે છે:

  • User-defined tags: તમે invent કરો છો <event>, <venue>; કંઈ predefined નથી (એ eXtensible છે)
  • Self-describing: tag names data ને document કરે છે
  • Platform અને language independent: plain text; કોઈ પણ OS, કોઈ પણ language તેને parse કરે છે
  • Separates data from presentation: કોઈ fonts નહીં, કોઈ colours નહીં, ફક્ત meaning
  • Strict: rules (next lessons) જે parsers refuse to bend કરે છે

Practical

events.xml: fest નું 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 (standard comparison)

AspectHTMLXML
PurposeDISPLAY dataCARRY અને store data
TagsPredefined (<h1>, <p>)User-defined (<event>, <venue>)
RulesForgiving: browsers guessStrict: parsers errors ને refuse કરે છે
CaseInsensitiveSensitive: <Name> એ <name> નથી
PresentationBuilt inNone: consumers decide કરે છે

Quiz

XML primarily શું કરવા માટે designed થયેલું છે?

  1. data ને browser માં attractively display કરવું
  2. data ને self-describing form માં store અને transport કરવું
  3. web pages build કરવા માટે HTML ને replace કરવું
  4. faster networks માટે data ને compress કરવું
Show the answer

data ને self-describing form માં store અને transport કરવું

XML એ labelled dabba છે: તે data ને meaning સાથે carry કરે છે અને looks વિશે કંઈ કહેતું નથી. Option A એ HTML નું job છે, અને display-vs-carry એ THE exam distinction છે 2 વચ્ચે. Option C તેમના relationship ને misread કરે છે: તેઓ colleagues છે different jobs સાથે, અને FestConnect બંને ને use કરે છે (HTML show કરવા માટે, XML store કરવા માટે). Option D almost backwards છે: self-describing tags XML files ને raw data કરતાં LARGER બનાવે છે, price paid willingly readability અને independence માટે.

Think first

તમે આખા semester દરમિયાન XML લખ્યું છે

tap કરતા પહેલા: BCA305-02 માં, Android subject, તમે ક્યાં already XML files ને write કરી રહ્યા હતા આ unit ના theory વગર?

Show the answer

Everywhere: દરેક layout file (activity_main.xml, LinearLayouts અને TextViews) અને AndroidManifest.xml એ XML documents છે: user-defined-by-Google tags, એક root element, strict nesting, attributes quotes માં. Android એ XML ને exactly characteristics માટે choose કર્યું જે આ lesson listed કરે છે: self-describing, platform-neutral, data-not-presentation. એટલે next 4 lessons ના rules new discipline નથી; તે grammar છે જે તમે already obey કરી રહ્યા હતા, હવે named.

Watch out

બે first-week misconceptions

"XML એ advanced HTML છે": no. Different purpose (carry vs display), different tag origin (yours vs predefined), different strictness. comparison table એ answer scheme છે; તેની rows ને learn કરો.

"browser મારા XML ને fix કરશે": browsers broken HTML ને daily rescue કરે છે, અને તે mercy એ bad habits ને train કર્યું. XML parsers ill-formed documents ને outright REFUSE કરે છે: એક unclosed tag અને આખી file reject થાય છે. Strictness એ feature છે: machines exchanging data guesses ને afford નથી કરી શકતા.

Theory

જ્યાં આ unit જાય છે

events.xml હવે FestConnect નું single source of truth છે, અને subject નો rest machinery ને તેની આસપાસ build કરે છે: jQuery (Unit 2) pages ને react કરવા માટે, JSON (Unit 3) XML નો leaner modern rival same job માટે, AJAX (Unit 4) data ને fetch કરવા માટે without reloading, અને Node.js (Unit 5) તેને serve કરવા માટે. First, though, grammar: exactly શું XML file ને legal બનાવે છે, starting with declarations, tags અને elements next lesson.

Summary

Key takeaways

  • XML data ને store અને transport કરે છે self-describing, user-defined tags માં; તે ક્યારેય presentation ને dictate નથી કરતું.
  • eXtensible = તમે tags ને invent કરો છો: <event>, <venue>, whatever data ને need હોય.
  • Plain text, platform અને language independent: એક file site, app, અને whatever comes next ને feed કરે છે.
  • HTML predefined, forgiving tags સાથે display કરે છે; XML user-defined, strict ones સાથે carry કરે છે.
  • Uses: data storage, systems વચ્ચે exchange, configuration (Android layouts અને manifest), RSS, SVG.
  • Parsers ill-formed XML ને refuse કરે છે: strictness એ છે જે machine exchange ને trustworthy બનાવે છે.
  • Memory hook: HTML એ plate છે, XML એ 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