XML
🎬 This chapter has a 12:38 video: Web Services →Every March, thousands of schools send their students’ marks to the board. The board’s computer does not want a nice-looking page; it wants to know which number is a roll number and which is the marks. XML is one way to label data so that another computer can tell.
1What XML is
Extensible means it can be extended — you can add any tags you need. Here is one student’s result in XML. Nobody defined <marks> in advance; the school chose it, and the tag says exactly what 91 is.
<?xml version="1.0"?>
<result>
<student>
<name>Aman</name>
<class>12</class>
<marks>91</marks>
</student>
</result>Send the correct document, then try each mistake. Drag sideways to turn.
<?xml version="1.0"?>
<result>
<student>
<name>Aman</name>
<class>12</class>
<marks>91</marks>
</student>
</result>✓ Well-formed: every tag is closed, in order, inside one root element.
2XML’s rules are strict
Because a computer has to read XML without guessing, every XML document must follow these rules. The lab’s mistakes break one each.
- Every opening tag has a closing tag:
<marks>91</marks>. - XML is case-sensitive:
<Name>and<name>are different tags, so one cannot close the other. - Tags close in the reverse order they opened: the one opened last closes first.
- There is exactly one root element that holds everything else (here,
<result>).
A document that follows the rules is called well-formed. If it breaks even one, a program reading it stops and rejects the whole document. (Every verdict in the lab was checked against Python’s own XML reader.)
3From the board papers
▶Show the answer
Extensible Markup Language.
▶Show the answer
(C). XML stores and transports data. It is a markup language, not a programming language — it cannot calculate or make decisions — and it is not the same as HTML.
4Check yourself
Why is this XML rejected? <Marks>91</marks>
What does the X in XML — Extensible — mean?