The Wayback Machine - https://web.archive.org/web/20240530175815/https://www.geeksforgeeks.org/xml-basics/
Open In App

XML | Basics

Last Updated : 29 Oct, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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 structures such 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




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


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. Users 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


Similar Reads

Web technologies | HTML and XML | Question 1
Which of the following is an advantage of putting presentation information in a separate CSS file rather than in HTML itself? (A) The content becomes easy to manage (B) Becomes easy to make site for different devices like mobile by making separate CSS files (C) CSS Files are generally cached and therefore decrease server load and network traffic. (
1 min read
Displaying XML Using CSS
XML stands for Extensible Markup Language. It is a dynamic markup language. It is used to transform data from one form to another form. An XML file can be displayed using two ways. These are as follows :- Cascading Style Sheet Extensible Stylesheet Language Transformation Displaying XML file using CSS : CSS can be used to display the contents of th
4 min read
Java Architecture for XML Binding ( JAXB ) | Set-1
Java Architecture for XML Binding (JAXB) defines an API for reading and writing Java objects to and from XML documents. JAXB gives Java developers an efficient and standard way of mapping between XML and Java code. JAXB makes it easier for developers to extend their applications with XML and Web Services technologies.At First JAXB was developed as
4 min read
Displaying XML Using XSLT
XSLT stands for Extensible Stylesheet Language Transformation. XSLT is used to transform XML document from one form to another form. XSLT uses Xpath to perform matching of nodes to perform these transformation . The result of applying XSLT to XML document could be an another XML document, HTML, text or any another document from technology perspecti
3 min read
Difference between JSON and XML
JSON (JavaScript Object Notation) is a lightweight data-interchange format and it completely language independent. It is based on the JavaScript programming language and easy to understand and generate. Example : C/C++ Code {&quot;Geeks&quot;:[ { &quot;firstName&quot;:&quot;Vivek&quot;, &quot;lastName&quot;:&quot;Kothari&quot; }, { &quot;firstName
2 min read
XML | Syntax
Prerequisite: XML | Basics In this article, we are going to discuss XML syntax rule which is used while writing an XML document or an XML application. It is a very simple and straight forward to learn and code. Below is a complete XML document to discuss each component in detail. C/C++ Code &amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=
3 min read
XML | Tags
XML tags are the important features of XML document. It is similar to HTML but XML is more flexible then HTML. It allows to create new tags (user defined tags). The first element of XML document is called root element. The simple XML document contain opening tag and closing tag. The XML tags are case sensitive i.e. &lt;root&gt; and &lt;Root&gt; bot
2 min read
XML | Elements
The XML elements are the basic building block of the XML document. It is used as a container to store text elements, attributes, media objects etc. Every XML documents contain at least one element whose scopes are delimited by start and end tags or in case of empty elements it is delimited by an empty tag. Syntax: &lt;element-name attributes&gt; Co
2 min read
XML | Attributes
Prerequisite: XML | BasicsThe XML attribute is a part of an XML element. The addition of attribute in XML element gives more precise properties of the element i.e, it enhances the properties of the XML element.Syntax: &lt;element_name attribute1 attribute2 ... &gt; Contents... &lt;/element_name&gt; In the above syntax element_name is the name of an
3 min read
How to convert XML file into array in PHP?
Given an XML document and the task is to convert an XML file into PHP array. To convert the XML document into PHP array, some PHP functions are used which are listed below: file_get_contents() function: The file_get_contents() function is used to read a file as string. This function uses memory mapping techniques which are supported by the server a
2 min read