XML

Introduction

XML (Extensible Markup Language) is a flexible, text-based format used to store and transport data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. XML is widely used for data exchange between systems, configuration files, and web services. Unlike HTML, XML focuses on describing data rather than displaying it, allowing users to create their own custom tags.


Syntax

<?xml version="1.0" encoding="UTF-8"?>
<note>
  <to>Alice</to>
  <from>Bob</from>
  <heading>Reminder</heading>
  <body>Don't forget our meeting at 10 AM!</body>
</note>
  • XML documents start with an optional declaration: <?xml version="1.0" encoding="UTF-8"?>

  • Elements are defined by start tags <tag> and end tags </tag>.

  • Elements can contain text, other elements (nested), or be empty (<tag/>).

  • Tags are case-sensitive.

  • Attributes provide additional information inside the start tag: <tag attribute="value">.

  • Proper nesting and closing of tags are mandatory for well-formed XML.

Last updated