XML | Basics

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.The design goals of XML focus on simplicity,generality,and usability across the Internet.It is a textual data format with strong support via Unicode for different human languages. Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structuressuch as those used in web services.

  1. XML stands for eXtensible Markup Language
  2. XML is a markup language like HTML
  3. XML is designed to store and transport data
  4. XML is designed to be self-descriptive

Differences between XML and HTML

XML and HTML were designed with different goals:

  • XML is designed to carry data emphasizing on what type of data it is.
  • HTML is designed to display data emphasizing on how data looks
  • XML tags are not predefined like HTML tags.
  • HTML is a markup language whereas XML provides a framework for defining markup languages.
  • HTML is about displaying data,hence it is static whereas XML is about carrying information,which makes it dynamic.

EXAMPLE :
XML code for a note is given below

HTML code for the note is given below

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<h1>Note</h1>
<body>
<p>To:RAJ
<br>
From:RAVI
</p>
<h1>Reminder</h1>
<p>Meeting at 8am</p>
</body>
</html>

chevron_right


OUTPUT :

Note : The output in both the cases is same but while using HTML we have used predefined tags like p tag and h1 tag whereas while using XML we have used self defined tags like “To” tag and “from” tag.

Another Example :
The XML above is quite self-descriptive:

  • It has sender information.
  • It has receiver information.
  • It has a heading.
  • It has a message body.
  • The tags in the example below 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 tag, h1 tag, etc.While in XML, the author must define both the tags and the document structure.

Input :

Output :

Basically XML above does not do anything. XML is just information wrapped in tags. User must require a piece of software to send, receive, store, or display it.

XML makes web development User Friendly : Many computer systems contain data in incompatible formats. Exchanging data between incompatible systems or upgraded systems is a time-consuming task for web developers. Large amounts of data must be converted, and incompatible data is often lost. XML stores data in plain text format. This provides a software- and hardware-independent way of storing, transporting, and sharing data.

XML is Extensible : XML applications will work as expected even if data is edited i.e. added or removed. Example :The above note is edited into a newer version by adding date tag and hour tag , and by removing the heading tag.
Previous version

New Version

Quiz on HTML and XML

This article is contributed by Shubrodeep Banerjee. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.



My Personal Notes arrow_drop_up


Article Tags :

3


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.