Home in XML
What is XML?
XML (eXtensible Markup Language) is a markup language designed to store and transport data. It is both human-readable and machine-readable. Unlike HTML, which is used to display data, XML is used to describe and structure data.
Key Features of XML
Self-descriptive structure:
Tags describe the data.
Example:
<person> <name>John</name> <age>30</age></person>
Custom tags:
You can define your own tags based on the structure of the data you're working with.
Hierarchical (tree) structure:
Data is organized in a nested, parent-child structure.
Platform-independent and language-independent:
Can be used across different systems and programming environments.
Supports Unicode:
Useful for internationalization (handling of different languages and scripts).
Basic Syntax Rules
Every tag must be closed:
<tag>content</tag>Tags are case-sensitive:
<Name>and<name>are different.
Elements must be properly nested:
<a><b></b></a> <!-- correct --><a><b></a></b> <!-- incorrect -->The document must have a single root element:
<root> <child1></child1> <child2></child2></root>
XML Declaration (Optional but Recommended)
Placed at the top of the document:
<?xml version="1.0" encoding="UTF-8"?>Example XML Document
<?xml version="1.0" encoding="UTF-8"?><bookstore> <book> <title>Learn XML</title> <author>Jane Doe</author> <price>29.99</price> </book> <book> <title>Mastering XML</title> <author>John Smith</author> <price>39.99</price> </book></bookstore>Common Uses of XML
Configuration files (e.g.,
.xmlin Java apps)Web services (SOAP)
Data interchange (between systems and applications)
RSS feeds
Office document formats (e.g., DOCX, XLSX are ZIP files containing XML)
Related Technologies
XSLT: For transforming XML documents
XPath: For querying XML data
XML Schema (XSD): For defining the structure and data types in an XML document
DTD (Document Type Definition): An older schema definition system
Would you like to see how to read XML using a programming language (like PHP, JavaScript, or Python)?