What is the XML file format?
.xml files store data in the Extensible Markup Language format, a plain-text standard developed by the W3C. XML files can represent any data structure in plain text, making them suitable for storing, sharing and transporting data between applications across the internet.
XML uses markup structures - nested tags and attributes - that define the rules an encoding process must follow to produce documents that are both machine-readable and human-readable. It was designed as a more accessible implementation of SGML (Standard Generalized Markup Language), simplified for web use. Files typically begin with the declaration <?xml version="1.0" encoding="UTF-8"?>, and the MIME type is application/xml.
XML files use Unicode encoding (UTF-8 by default) and can be opened and edited with any standard text editor. Because the format is self-describing - each element is named and nested within a clear hierarchy - the data can be inspected without dedicated software, though processing or querying it programmatically requires a parser or a query language such as XPath.
XML is in many ways similar to .HTML, as both formats use markup language to represent structured content. HTML is focused on web page presentation and interaction, while XML describes content in relation to the data itself. The two formats are used together in many web applications. XML also serves as the foundation for related standards such as .XSD validation schemas, .XSL transformation stylesheets, and .RSS syndication feeds.
Security & safety
RISK: MEDIUMAn XML file is plain text and contains no executable code, so reading one is safe. The real risks are at the PARSER, not the file: XML External Entity (XXE) attacks abuse <!DOCTYPE>/<!ENTITY> declarations to read local files or trigger network requests, and "billion laughs" entity-expansion can exhaust memory (denial of service). These only matter when software parses untrusted XML with external entities and DTD processing enabled - modern parsers disable these by default. For an end user just opening an .xml to read it, there's no danger; the caution is for developers processing untrusted XML. Also beware files that look like 'data.xml' but are actually something else renamed.
Format details
in a nutshellPrograms that open XML files
Technical details
deep spec| File encoding | Unicode only; UTF-8 is the default when no declaration is present; UTF-16 and UTF-32 are supported and must be declared in the XML prolog |
| MIME type | `application/xml` (primary, per RFC 7303); `text/xml` accepted for legacy compatibility; specific dialects may register their own type (e.g. `application/rss+xml`) |
| File signature | No fixed binary magic number; files typically open with the optional XML declaration `<?xml` (hex `3C 3F 78 6D 6C`); a UTF-8 BOM (`EF BB BF`) or UTF-16 BOM (`FF FE` / `FE FF`) may precede it |
| Document structure | Strict hierarchy: exactly one root element; unlimited nesting of child elements; opening tags may carry named, quoted attributes; the entire tree must be well-formed |
| Well-formedness rules | All tags must be closed or self-closed; elements must not cross-nest; attribute values must be quoted; five predefined entities (&, <, >, ", ') handle reserved characters |
| Validation mechanisms | DTD (Document Type Definition - inline or external `.dtd` file, older standard) and XSD (XML Schema Definition - a `.xsd` file itself written in XML, with a richer type system); Schematron offers rule-based validation |
| Namespace support | `xmlns` and `xmlns:prefix` declarations bind element and attribute names to a URI, preventing collisions when combining vocabularies from multiple sources |
| CDATA sections | `<![CDATA[...]]>` blocks let raw text containing <, >, and & appear without entity escaping; useful for embedding HTML fragments or script code |
| Processing instructions | `<?target instruction?>` syntax embeds application-specific directives (e.g. `<?xml-stylesheet type="text/xsl" href="style.xsl"?>`) outside the XML data model |
| Query languages | XPath 1.0/2.0/3.1 addresses individual nodes inside a document; XQuery provides SQL-style querying over XML datasets; both are W3C-standardised |
| XSLT transformation | `.xml` files can be transformed to HTML, plain text, or other XML vocabularies at runtime by an XSLT processor merging the source document with a `.xsl` or `.xslt` stylesheet |
| Comment syntax | `<!-- text -->` comments may appear anywhere outside a tag; double hyphens are forbidden inside the comment body; comments are excluded from the XML data model |
| Newline normalization | Conforming parsers normalize \r\n and bare \r sequences to \n before processing, ensuring consistent line-ending behavior across platforms |
| Entity declarations | Named entities (&name;) and numeric character references (&#nnnn; decimal or &#xHHHH; hex) embed any Unicode code point; custom entities can be declared in a DTD |
| Prolog structure | An XML document consists of an optional XML declaration, an optional DOCTYPE declaration, optional processing instructions and comments, followed by exactly one root element |
| Dialect ecosystem | XML is the base syntax for XHTML, SVG, RSS, Atom, DOCX (Office Open XML), EPUB, KML, and configuration formats used by Android, Maven, Spring, and Java EE |
| Released | 1998 (XML 1.0 W3C Recommendation, February 10, 1998) |
| Open standard | Yes · royalty-free |
| Specification | www.w3.org |
XML conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about XML files.