Here is the Introduction of XML:
XML, or eXtensible Markup Language, is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable.
• It is often used to represent structured data and to exchange information between systems over the internet
• It is a software- and hardware-independent tool for storing and transporting data.
• It is a markup language much like HTML
• XML documents have a hierarchical structure, organized as a tree.
• The “X” in XML stands for extensible. This means that you can define your own tags and attributes to represent data in a way that is meaningful for your specific application or domain.
Note: XML is a markup language similar to HTML (Hypertext Markup Language). However, while HTML is designed to display data, XML is designed to store and transport data.
Difference between XML and HTML:
XML Syntax Rules
XML documents must contain one root element that is the parent of all other elements:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
Example:-
<root>
<person>
<details>Personal Information</details>
<name>John Doe</name>
<age>30</age>
<address>
<street>Main Street</street>
<city>City</city>
<country>Country</country>
</address>
</person>
</root>
Comments in XML
The syntax for writing comments in XML is similar to that of HTML:
<root>
< !-- This is a comment -- >
<child>
<! -- Comments can be added anywhere in the XML document -- >
<subchild>This is some content</subchild>
</child>
</root>
Structure of XML
The structure of an XML file consists of elements organized in a hierarchical manner. Each XML file must have a single root element that encloses all other elements.
• Elements can contain text, attributes, and other elements, forming a tree-like structure.
<?xml version="1.0" encoding="UTF-8"?>
<library>
<book ISBN="978-3-16-148410-0">
<title>XML Basics</title>
<author>John Doe</author>
<publication_year>2020</publication_year>
</book>
<book ISBN="978-3-16-148411-7">
<title>Advanced XML</title>
<author>Jane Smith</author>
<publication_year>2021</publication_year>
</book>
</library>