json2toon.co
Secure

XML Format Specification & Data Interchange Guide

XML (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 a flexible way to create common information formats and share both the format and the data on the World Wide Web, intranets, and elsewhere.

Introduction

XML was designed to store and transport data, focusing on what data is, rather than how it looks. Unlike HTML, XML tags are not predefined; you must define your own tags. It is a W3C Recommendation and widely used for data interchange.

Key Features

  • Extensible: Users can define their own tags and document structures.
  • Platform Independent: Text-based format readable by any system.
  • Self-Describing: The data structure is embedded within the document.
  • Strict Syntax: Ensures data integrity and easier parsing.

Syntax

XML documents form a tree structure that starts at "the root" and branches to "the leaves".

Example

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Tove</to>
  <from>Jani</from>
  <heading>Reminder</heading>
  <body>Don't forget me this weekend!</body>
</note>

Attributes

XML elements can have attributes, just like HTML. Attributes provide additional information about an element.

<person gender="female">
  <firstname>Anna</firstname>
  <lastname>Smith</lastname>
</person>

Use Cases

  • Web Services: SOAP (Simple Object Access Protocol) is XML-based.
  • Configuration: Many enterprise applications use XML for configuration (e.g., Java Spring, Maven).
  • Document Formats: SVG (Scalable Vector Graphics), RSS (Really Simple Syndication), and Office Open XML (docx, xlsx) are all XML-based.

Related Formats

Compare XML with other data formats:

  • JSON - A lightweight alternative often used in modern web APIs.
  • YAML - A more human-readable format often used for configuration.

Resources