Open In App

XML Tutorial

Last Updated : 15 Apr, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

XML, or Extensible Markup Language, is a way to structure and organize information in a text format that is easy for computers to read. It uses tags, similar to those in HTML, to define different types of data inside a document. XML allows data to be stored and shared in a consistent and structured manner, which makes it useful for tasks like storing configuration settings, exchanging data between different systems, and managing information in databases.

XML-tutorial

Basic Example of XML

Example1: This illustrates a simple "note" structure with sender, receiver, heading, and body elements enclosed within a "note" element, representing a basic structured data format for storing and exchanging information.

XML
<?xml version="1.0" encoding="UTF-8"?>
<note>
   <to>reciever</to>
   <from>sender</from>
   <heading>Heading</heading>
   <body>Add Content Here</body>
</note>

Output:

Screenshot-2024-07-05-113106
xml

Example 2: This illustrates a "bookstore" with two "book" entries categorized as fiction and non-fiction. Each book entry includes details such as title, author, publication year, and price, structured for managing and displaying information about books within an XML format.

XML
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
   <book category="fiction">
       <title>GFG</title>
       <author>Fictional book </author>
       <year>2002</year>
       <price>5000</price>
   </book>
    <book category="non-fiction">
      <title>GFG 2 </title>
      <author>non fictional book </author>
      <year>2020</year>
      <price>1000</price>
    </book>
</bookstore>

Output:

Screenshot-2024-07-05-113238

Why Study XML ?

XML lets you create structured documents using custom tags, making it easier to share data across different systems. Learning XML helps simplify data organization and integration in web development and software applications.

What you will learn?

This tutorial will give you an idea about XML:

Important XML Standards

This tutorial will also delve into the following important XML standards:

Features

  • Extensibility: XML allows you to create your own tags and structures to organize and store diverse types of data.
  • Hierarchical Structure: Data in XML is organized in a tree-like structure with nested elements, making it easy to represent relationships between different pieces of information.
  • Self-Explanatory : XML documents use tags to define data elements, making them understandable by both humans and machines without relying on a specific format.
  • Platform-Independent: XML can be used on any operating system and with any programming language, guarantees compatibility and easy data exchange.
  • Vendor-Neutral: XML is a standardized format not tied to any particular company or technology, ensuring widespread support and adoption.
  • Support for Metadata: XML allows embedding metadata that describes the data's structure, semantics, and other attributes, enhancing document usefulness.
  • Parsing and Processing: XML parsers are widely available for reading and manipulating XML data, facilitating its integration into various applications.
  • Integration with Other Standards: XML can be combined with other standards like XPath, XSLT, and XML Schema for querying, transforming, and defining document structures.
  • Well-Defined Standards: XML is based on established standards maintained by the W3C, ensuring consistency and interoperability across different systems and tools.

Next Article

Similar Reads