XML is a specification for creating custom markup languages. It allows computers to share structured data by defining rules for encoding documents in a format that is both human-readable and machine-readable. XML documents use tags to define the structure and meaning of content. Well-formed XML documents follow syntax rules, while valid documents also conform to semantic rules defined in an external DTD or schema file. This ensures XML documents can be processed and shared reliably across different computers and platforms.