What is XML and How Does it Work?
Advertisement
Ad
What is XML?
XML (eXtensible Markup Language) is a language for storing and transporting data in a structured, human-readable format. Unlike HTML, you define your own tags.
An XML Document
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="tech">
<title>Clean Code</title>
<author>Robert Martin</author>
<price>35</price>
</book>
</bookstore>
Key Rules
- One root element wraps everything.
- All tags must close and nest properly.
- Tags are case-sensitive.
- Attribute values must be quoted.
Where XML is Used
- Config files (Maven
pom.xml, Android layouts). - RSS feeds & sitemaps.
- SOAP web services.
- Office documents (.docx is zipped XML).
FAQs
XML vs HTML?
HTML displays data with fixed tags; XML stores data with custom tags. More in our XML guides.
Is XML still relevant?
Yes for config and enterprise systems, though JSON dominates web APIs now.
