XML Compatibility: Apps, Versions and Common Limits

November 08, 2026 · XML.now Editorial · XML Essentials

Understand why a valid XML file can behave differently across applications and devices.

XML Version Compatibility: 1.0 vs. 1.1

The W3C XML Recommendation defines two major versions with incompatible character models.

XML 1.0 (Fifth Edition, 2008) restricts content characters to Unicode code points U+0009, U+000A, U+000D, and U+0020–U+D7FF, U+E000–U+FFFD, U+10000–U+10FFFF. Control characters beyond tab, line feed, and carriage return are forbidden. Names must begin with a letter, underscore, or colon, followed by letters, digits, hyphens, underscores, colons, or periods. Every mainstream parser supports this version.

XML 1.1 (Second Edition, 2006) expands the character repertoire to include Unicode characters from later versions and permits control characters (U+0001–U+001F, except U+0000) when expressed as character references. A document declaring <?xml version="1.1"?> will be rejected outright by parsers built into Internet Explorer 6–8, libxml2 versions before 2.6.30, and Java SAX parsers shipped before 2010. Microsoft Excel (tested through Office 2021) opens XML 1.1 files without error but silently strips control characters from element content, which can corrupt data without warning.

Verification check: Pass a file containing <?xml version="1.1"?> to xmllint --version and confirm the parser reports XML 1.1 support. If the tool exits with an unsupported version error, the target environment does not handle 1.1.


Parser Modes and the Well-Formedness/Validity Gap

Applications distinguish between two conformance levels that the specification defines separately.

A well-formed document follows XML grammar rules: single root element, correctly nested tags, quoted attribute values, and proper character escaping. A well-formed document opens in any conforming parser regardless of schema.

A valid document is well-formed and additionally conforms to a Document Type Definition (DTD) or XML Schema (XSD) referenced within it. The specification does not require parsers to validate; many non-validating parsers ignore DTD and schema references entirely.

This creates a failure pattern: a file that is valid against a schema but not well-formed (e.g., an unescaped < in an attribute value) fails in every parser. A file that is well-formed but invalid against its schema opens in browsers and text editors but fails in applications that enforce schema validation, such as financial reporting tools or government document processors.

Observable check: Run xmllint --noout --valid file.xml. A non-zero exit code indicates schema invalidity. Run xmllint --noout file.xml without the --valid flag. If the first command fails but the second succeeds, the document is well-formed but invalid—the exact condition that causes cross-application failures.


Platform-Specific Parser Behaviors

Windows: MSXML and .NET Divergence

Internet Explorer and legacy Edge use the Microsoft XML parser (MSXML), which enforces strict namespace uniqueness. Duplicate xmlns declarations on the same element, which libxml2 and Expat tolerate, cause MSXML to raise a fatal error.

PowerShell's [xml] cast uses the .NET XmlReader. This parser accepts the malformed declaration <?xml encoding="utf-8"?> (missing the version pseudo-attribute) without error. A file that parses silently in PowerShell will fail on any conforming parser. The correct form is <?xml version="1.0" encoding="UTF-8"?>.

Notepad++ with the XML Tools plugin uses libxml2. This parser rejects raw \r characters (U+000D) when they appear outside of whitespace contexts in element content. Windows-generated XML from legacy tools often contains \r\n line endings; libxml2 normalizes \r\n to \n but treats a lone \r in non-whitespace position as a fatal well-formedness error.

macOS and Linux: libxml2 vs. Expat

libxml2 (used by Firefox, Safari, and GNOME tools) disables external entity expansion by default as a security measure against XXE attacks. A document containing <!ENTITY ext SYSTEM "http://example.com/data"> and referencing &ext; will parse without error, but the entity reference resolves to an empty string. The content is silently absent.

Expat (used by Python's xml.parsers.expat and many command-line tools) is a stream-oriented parser. It does not build a Document Object Model. Applications that attempt XPath queries or tree traversal on Expat-parsed data will fail unless the application layer constructs its own tree. Expat also halts at the first well-formedness error and does not report subsequent errors, making iterative debugging slower.

Verification check: Create a test file with <!DOCTYPE test [<!ENTITY ext SYSTEM "nonexistent.xml">]><root>&ext;</root>. Parse with the target application. If the entity reference produces content, external entity resolution is enabled. If it produces nothing or an error, resolution is disabled.


Mobile Parser Resource Limits

iOS Safari's XML parser imposes a default entity expansion limit of 10,000. A document with recursive entity definitions or deep nesting that triggers more than 10,000 expansions fails with a "parser too deep" error. This limit is not configurable without modifying the application layer.

Android 10 and earlier used a libxml2 binding with a 4 MB internal buffer for attribute values. An element with a single attribute value exceeding 4 MB—common when embedding Base64-encoded binary data—caused silent truncation. The parser reported success while discarding data beyond the 4 MB boundary. Android 12 and later raise an exception when this limit is exceeded.

Hard limit test: Construct an XML file with a single attribute containing 5 MB of text. Parse on the target Android version and compare the parsed attribute length to the original. A mismatch indicates truncation.


Unsupported Features Across Common Applications

External entity resolution is disabled by default in Microsoft Office 2016 and later, all major browsers (Chrome, Firefox, Edge), and most server-side XML processors. Documents that depend on external entities for content composition render incomplete or empty.

Default namespace declarations without a prefix—xmlns="http://example.com"—are valid XML but unsupported in Adobe InDesign CS6 and older CorelDRAW versions. These applications require an explicit prefix: xmlns:ex="http://example.com" with ex: on every element. The file parses but produces no visible output.

CDATA sections inside attribute values are forbidden by the specification. Some editors (XMLSpy, Oxygen) allow typing <![CDATA[...]]> in an attribute value during editing and escape the markers on save. Copying a CDATA section into an attribute value in a plain text editor produces a malformed file that fails at the first occurrence of <![CDATA[ inside an attribute.

Encoding declaration mismatches between the XML declaration and actual byte encoding produce failures that vary by parser age. A file saved as UTF-8 with a Byte Order Mark (BOM) but declaring encoding="UTF-16" will parse correctly in modern browsers, which detect the BOM and override the declaration. Parsers from before 2010 honor the declaration and attempt UTF-16 decoding on UTF-8 bytes, producing garbled output or a fatal error.


Cross-Application Compatibility Constraints

A file that meets all of the following conditions will open in every XML parser tested as of 2024:

  • Declares <?xml version="1.0" encoding="UTF-8"?> and is saved as UTF-8 without BOM.
  • Contains no external entity references.
  • Uses no XML 1.1 control characters, even as character references.
  • Keeps attribute values under 4 MB.
  • Keeps entity expansion chains under 10,000 total expansions.
  • Avoids default namespace declarations if targeting Adobe or Corel products.
  • Contains no CDATA sections within attribute values.
  • Uses \n line endings, not \r or \r\n, if targeting libxml2-based parsers.

Validation procedure: Run xmllint --noout --valid file.xml for well-formedness and schema validity. Run xmlstarlet val file.xml for Expat-based checking. Test the file on the oldest parser version in the target deployment environment. Any deviation from the constraints above introduces application-specific failure risk that the W3C specification does not address.


When XML Compatibility Is Not the Goal

Some formats use XML-like syntax but are not XML. Apple's iCalendar (.ics) format uses line-oriented key-value pairs that resemble XML attributes but lack a root element and closing tags—no XML parser can consume it. Microsoft Office Open XML (.docx, .xlsx) wraps XML files inside a ZIP archive; the individual XML files are not designed for standalone parsing and reference relationships across the archive that break when extracted. In these cases, attempting to make the file compatible with a generic XML parser is incorrect. Use the format's native processing library instead.