XML (eXtensible Markup Language) is a markup language that defines rules for encoding documents in a format that is both human-readable and machine-readable. It's designed to store and transport data, making it a popular choice for data exchange between different systems and applications.

Key Features

  • Self-describing: XML documents contain both data and metadata
  • Platform-independent: Works across different operating systems
  • Extensible: You can create your own custom tags
  • Hierarchical: Data is organized in a tree-like structure
  • Strict syntax: Well-formed documents follow specific rules

XML Structure Example

<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
    <book id="1">
        <title>Web Development Fundamentals</title>
        <author>John Smith</author>
        <price currency="USD">29.99</price>
        <category>Programming</category>
        <published>2024-01-15</published>
    </book>
    <book id="2">
        <title>Advanced JavaScript</title>
        <author>Jane Doe</author>
        <price currency="USD">39.99</price>
        <category>Programming</category>
        <published>2024-02-20</published>
    </book>
</bookstore>
                    

Common Use Cases

  • Configuration Files: Application settings and preferences
  • Data Exchange: Between different systems and APIs
  • Web Services: SOAP web services use XML for messaging
  • Document Storage: Structured document formats
  • RSS Feeds: Syndication of web content
  • Sitemaps: Website structure for search engines

XML vs JSON

XML
More verbose, supports attributes
JSON
Lighter, better for web APIs