Skip to main content

Introduction to XML

 XML is a software- and hardware-independent tool for storing and transporting data.


What is XML?

  • XML stands for eXtensible Markup Language
  • XML is a markup language much like HTML
  • XML was designed to store and transport data
  • XML was designed to be self-descriptive
  • XML is a W3C Recommendation

XML Does Not DO Anything

Maybe it is a little hard to understand, but XML does not DO anything.

This note is a note to Tove from Jani, stored as XML:


<note>
  <to>Sita</to>
  <from>Ram</from>
  <heading>Message</heading>
  <body>MIss You</body>
</note>


he XML above is quite self-descriptive:

  • It has sender information
  • It has receiver information
  • It has a heading
  • It has a message body

But still, the XML above does not DO anything. XML is just information wrapped in tags.


The Difference Between XML and HTML

XML and HTML were designed with different goals:

  • XML was designed to carry data - with focus on what data is
  • HTML was designed to display data - with focus on how data looks
  • XML tags are not predefined like HTML tags are

XML Does Not Use Predefined Tags

The XML language has no predefined tags.

The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document.

HTML works with predefined tags like <p>, <h1>, <table>, etc.

With XML, the author must define both the tags and the document structure.


XML is Extensible

Most XML applications will work as expected even if new data is added (or removed).

Imagine an application designed to display the original version of note.xml (<to> <from> <heading> <body>).

Then imagine a newer version of note.xml with added <date> and <hour> elements, and a removed <heading>.

The way XML is constructed, older version of the application can still work:


<note>
  <date>2015-09-01</date>
  <hour>08:30</hour>
  <to>Sita</to>
  <from>Ram</from>
  <body>Miss You</body>
</note>


XML Simplifies Things

  • XML simplifies data sharing
  • XML simplifies data transport
  • XML simplifies platform changes
  • XML simplifies data availability

Comments