XML File
Definition
XML stands for Extensible Markup Language, a W3C recommendation since 1998 and still on version 1.0 in practice, now in its fifth edition. A document has exactly one root element, every element that opens must close, attribute values must be quoted, and five characters carry special meaning — an ampersand, both angle brackets and both quote marks — so they appear in content as the entities amp, lt, gt, quot and apos. Most files open with a declaration naming the version and encoding, which is how a parser learns the character set when no HTTP header supplies one. Unlike HTML, XML defines no elements of its own: a schema or a convention supplies the vocabulary, which is why sitemaps, RSS feeds, SVG drawings and the innards of every Office document are all XML while sharing nothing but the syntax. The content type is application/xml, or a more specific one such as application/rss+xml or image/svg+xml where the vocabulary has its own.
Why It Matters
Well-formedness is not a style preference — it is a wall. A sitemap with a raw ampersand in a URL is rejected in full by Google Search Console, not row by row, so one bad character can cost you every URL in the file. The error message names a line and column rather than the problem, which makes a missing closing tag halfway down a 5,000-line feed tedious to find. XML also carries a security history worth knowing: external entity expansion, the XXE class of bug, lets a crafted document read files from a server that parses it with default settings. That matters little on a static host, which never parses what it serves, and a great deal in whatever consumes your file.
How It Works
Served as application/xml, an XML file opened directly in Chrome or Firefox shows a collapsible tree, and an ill-formed one shows a parse error at the first offending line instead of any content. That makes the browser a fast validator: publish the file, open it, and either you get a tree or you get the line number. A stylesheet processing instruction pointing at an XSLT file turns the raw data into a formatted page, which is how some RSS feeds present themselves as readable pages. Encoding follows a clear precedence — a charset in the HTTP Content-Type header wins, the XML declaration comes next, and UTF-8 is assumed if neither says otherwise. Compression helps more here than almost anywhere else, since repeated tag names give gzip a great deal to work with, often shrinking a feed by 80 per cent or more.
Real-World Example
A publisher hosts their podcast feed at shows.99helpers.site/feed.xml and points Apple Podcasts and Spotify at that address. The feed is a plain file on 99helpers, served as application/xml and reuploaded whenever an episode ships. Opening the URL in a browser is an immediate structural check before the directories fetch it — a tree means it parsed, a red error line means it did not. The address never changes, so no directory ever needs reconfiguring.
Common Mistakes
- ✕Building XML by string concatenation — an unescaped ampersand in a title or URL makes the whole document ill formed, and every downstream consumer rejects it entirely
- ✕Declaring an encoding in the prolog that does not match the bytes on disk — the file says UTF-8, the editor saved Windows-1252, and every accented character breaks the parse
- ✕Confusing XML with HTML because both use angle brackets — a browser repairs broken HTML and refuses to repair broken XML
- ✕Serving a feed as text/plain — some aggregators will not touch a response whose type says it is not XML
Related Terms
sitemap.xml
An XML file listing the pages of a site so search engines do not have to find them all by following links. It aids discovery; it does not affect ranking.
JSON File
JSON is a text format for structured data, built from objects, arrays, strings, numbers, true, false and null. It is the usual way one program hands data to another over HTTP, and the usual way a static page loads data it did not ship with.
SVG File
An SVG file is an image written as XML markup, describing shapes and paths instead of a grid of pixels. Because the browser draws it at render time, one file stays sharp at any size.
Character Encoding
A character encoding is the rule that maps the bytes in a file to the characters a person reads. Get it wrong and nothing errors — the text simply comes out as the wrong characters.
Gzip Compression
Gzip compression shrinks a response before it leaves the server and the browser expands it again on arrival. It is lossless, it has been supported by every browser for decades, and it typically cuts text files to a third of their original size.
Put a file online in seconds
Drop in a document, an image, a page or a whole static website and share the link — free, with no build step and no server to set up.
Host a file free →